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 packages that were |
7 |
< |
developed to solve common MD problems and perform robust simulations |
8 |
< |
. However, many of the codes are legacy programs that are either |
9 |
< |
poorly organized or extremely complex. Usually, these packages were |
10 |
< |
contributed by scientists without official computer science |
11 |
< |
training. The development of most MD applications are lack of strong |
12 |
< |
coordination to enforce design and programming guidelines. Moreover, |
13 |
< |
most MD programs also suffer from missing design and implement |
14 |
< |
documents which is crucial to the maintenance and extensibility. |
15 |
< |
Along the way of studying structural and dynamic processes in |
16 |
< |
condensed phase systems like biological membranes and nanoparticles, |
17 |
< |
we developed and maintained an Object-Oriented Parallel Simulation |
18 |
< |
Engine ({\sc OOPSE}). This new molecular dynamics package has some |
19 |
< |
unique features |
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 |
15 |
> |
Object-Oriented Parallel Simulation Engine ({\sc OOPSE}). This new |
16 |
> |
molecular dynamics package has some unique features |
17 |
|
\begin{enumerate} |
18 |
|
\item {\sc OOPSE} performs Molecular Dynamics (MD) simulations on non-standard |
19 |
|
atom types (transition metals, point dipoles, sticky potentials, |
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. |
88 |
< |
|
89 |
< |
Patterns are usually described using a format that includes the |
90 |
< |
following information: |
94 |
< |
\begin{enumerate} |
95 |
< |
\item The \emph{name} that is commonly used for the pattern. Good pattern names form a vocabulary for |
96 |
< |
discussing conceptual abstractions. a pattern may have more than one commonly used or recognizable name |
97 |
< |
in the literature. In this case it is common practice to document these nicknames or synonyms under |
98 |
< |
the heading of \emph{Aliases} or \emph{Also Known As}. |
99 |
< |
\item The \emph{motivation} or \emph{context} that this pattern applies |
100 |
< |
to. Sometimes, it will include some prerequisites that should be satisfied before deciding to use a pattern |
101 |
< |
\item The \emph{solution} to the problem that the pattern |
102 |
< |
addresses. It describes how to construct the necessary work products. The description may include |
103 |
< |
pictures, diagrams and prose which identify the pattern's structure, its participants, and their |
104 |
< |
collaborations, to show how the problem is solved. |
105 |
< |
\item The \emph{consequences} of using the given solution to solve a |
106 |
< |
problem, both positive and negative. |
107 |
< |
\end{enumerate} |
108 |
< |
|
109 |
< |
As one of the latest advanced techniques emerged from |
110 |
< |
object-oriented community, design patterns were applied in some of |
111 |
< |
the modern scientific software applications, such as JMol, {\sc |
112 |
< |
OOPSE}\cite{Meineke2005} and PROTOMOL\cite{Matthey2005} |
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}. |
93 |
|
|
99 |
|
variable, the logging utility which reports error and warning |
100 |
|
messages to the console in {\sc OOPSE} is a good candidate for |
101 |
|
applying the Singleton pattern to avoid the global namespace |
102 |
< |
pollution.Although the singleton pattern can be implemented in |
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}. IntegratorFactory class is |
106 |
< |
declared as |
107 |
< |
|
105 |
> |
static data approach in {\sc OOPSE}. The declaration and |
106 |
> |
implementation of IntegratorFactory class are given by declared in |
107 |
> |
List.~\ref{appendixScheme:singletonDeclaration} and |
108 |
> |
Scheme.~\ref{appendixScheme:singletonImplementation} respectively. |
109 |
> |
Since constructor is declared as protected, a client can not |
110 |
> |
instantiate IntegratorFactory directly. Moreover, since the member |
111 |
> |
function getInstance serves as the only entry of access to |
112 |
> |
IntegratorFactory, this approach fulfills the basic requirement, a |
113 |
> |
single instance. Another consequence of this approach is the |
114 |
> |
automatic destruction since static data are destroyed upon program |
115 |
> |
termination. |
116 |
|
\begin{lstlisting}[float,caption={[A classic Singleton design pattern implementation(I)] The declaration of of simple Singleton pattern.},label={appendixScheme:singletonDeclaration}] |
117 |
|
|
118 |
|
class IntegratorFactory { |
127 |
|
|
128 |
|
\end{lstlisting} |
129 |
|
|
144 |
– |
The corresponding implementation is |
145 |
– |
|
130 |
|
\begin{lstlisting}[float,caption={[A classic implementation of Singleton design pattern (II)] The implementation of simple Singleton pattern.},label={appendixScheme:singletonImplementation}] |
131 |
|
|
132 |
|
IntegratorFactory::instance_ = NULL; |
140 |
|
|
141 |
|
\end{lstlisting} |
142 |
|
|
159 |
– |
Since constructor is declared as protected, a client can not |
160 |
– |
instantiate IntegratorFactory directly. Moreover, since the member |
161 |
– |
function getInstance serves as the only entry of access to |
162 |
– |
IntegratorFactory, this approach fulfills the basic requirement, a |
163 |
– |
single instance. Another consequence of this approach is the |
164 |
– |
automatic destruction since static data are destroyed upon program |
165 |
– |
termination. |
143 |
|
|
144 |
|
\subsection{\label{appendixSection:factoryMethod}Factory Method} |
145 |
|
|
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 List.~\ref{appendixScheme:factoryDeclaration}). If |
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 List.~\ref{integratorCreator}) |
155 |
< |
which utilizes the modern C++ template technique to avoid excess |
156 |
< |
subclassing. |
154 |
> |
invoke the corresponding creator (see |
155 |
> |
Scheme.~\ref{appendixScheme:integratorCreator}) which utilizes the |
156 |
> |
modern C++ template technique to avoid excess subclassing. |
157 |
|
|
158 |
|
\begin{lstlisting}[float,caption={[The implementation of Parameterized Factory pattern (I)]Source code of IntegratorFactory class.},label={appendixScheme:factoryDeclaration}] |
159 |
|
|
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 List.~\ref{appendixScheme:element}). Since the hierarchies |
218 |
> |
in Scheme.~\ref{appendixScheme:element}). Since the hierarchies |
219 |
|
remains stable, it is easy to define a visit operation (see |
220 |
< |
List.~\ref{appendixScheme:visitor}) for each class of StuntDouble. |
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. |
277 |
|
virtual void visit(RigidBody* rb); |
278 |
|
}; |
279 |
|
|
303 |
– |
class SSDAtomVisitor:public BaseAtomVisitor{ public: |
304 |
– |
virtual void visit(Atom* atom); |
305 |
– |
virtual void visit(DirectionalAtom* datom); |
306 |
– |
virtual void visit(RigidBody* rb); |
307 |
– |
}; |
308 |
– |
|
280 |
|
class CompositeVisitor: public BaseVisitor { |
281 |
|
public: |
282 |
|
|
285 |
|
virtual void visit(Atom* atom) { |
286 |
|
VisitorListIterator i; |
287 |
|
BaseVisitor* curVisitor; |
288 |
< |
for(i = visitorList.begin();i != visitorList.end();++i) { |
288 |
> |
for(i = visitorScheme.begin();i != visitorScheme.end();++i) { |
289 |
|
atom->accept(*i); |
290 |
|
} |
291 |
|
} |
293 |
|
virtual void visit(DirectionalAtom* datom) { |
294 |
|
VisitorListIterator i; |
295 |
|
BaseVisitor* curVisitor; |
296 |
< |
for(i = visitorList.begin();i != visitorList.end();++i) { |
296 |
> |
for(i = visitorScheme.begin();i != visitorScheme.end();++i) { |
297 |
|
atom->accept(*i); |
298 |
|
} |
299 |
|
} |
303 |
|
std::vector<Atom*> myAtoms; |
304 |
|
std::vector<Atom*>::iterator ai; |
305 |
|
myAtoms = rb->getAtoms(); |
306 |
< |
for(i = visitorList.begin();i != visitorList.end();++i) {{ |
306 |
> |
for(i = visitorScheme.begin();i != visitorScheme.end();++i) {{ |
307 |
|
rb->accept(*i); |
308 |
|
for(ai = myAtoms.begin(); ai != myAtoms.end(); ++ai){ |
309 |
|
(*ai)->accept(*i); |
315 |
|
protected: |
316 |
|
VistorListType visitorList; |
317 |
|
}; |
347 |
– |
|
318 |
|
\end{lstlisting} |
319 |
|
|
320 |
|
\section{\label{appendixSection:concepts}Concepts} |
485 |
|
and other atoms of type $B$, $g_{AB}(r)$. {\tt StaticProps} can |
486 |
|
also be used to compute the density distributions of other molecules |
487 |
|
in a reference frame {\it fixed to the body-fixed reference frame} |
488 |
< |
of a selected atom or rigid body. |
488 |
> |
of a selected atom or rigid body. Due to the fact that the selected |
489 |
> |
StuntDoubles from two selections may be overlapped, {\tt |
490 |
> |
StaticProps} performs the calculation in three stages which are |
491 |
> |
illustrated in Fig.~\ref{oopseFig:staticPropsProcess}. |
492 |
|
|
493 |
+ |
\begin{figure} |
494 |
+ |
\centering |
495 |
+ |
\includegraphics[width=\linewidth]{staticPropsProcess.eps} |
496 |
+ |
\caption[A representation of the three-stage correlations in |
497 |
+ |
\texttt{StaticProps}]{This diagram illustrates three-stage |
498 |
+ |
processing used by \texttt{StaticProps}. $S_1$ and $S_2$ are the |
499 |
+ |
numbers of selected stuntdobules from {\tt -{}-sele1} and {\tt |
500 |
+ |
-{}-sele2} respectively, while $C$ is the number of stuntdobules |
501 |
+ |
appearing at both sets. The first stage($S_1-C$ and $S_2$) and |
502 |
+ |
second stages ($S_1$ and $S_2-C$) are completely non-overlapping. On |
503 |
+ |
the contrary, the third stage($C$ and $C$) are completely |
504 |
+ |
overlapping} \label{oopseFig:staticPropsProcess} |
505 |
+ |
\end{figure} |
506 |
+ |
|
507 |
|
There are five seperate radial distribution functions availiable in |
508 |
|
OOPSE. Since every radial distrbution function invlove the |
509 |
|
calculation between pairs of bodies, {\tt -{}-sele1} and {\tt |
547 |
|
\end{description} |
548 |
|
|
549 |
|
The vectors (and angles) associated with these angular pair |
550 |
< |
distribution functions are most easily seen in the figure below: |
550 |
> |
distribution functions are most easily seen in |
551 |
> |
Fig.~\ref{oopseFig:gofr} |
552 |
|
|
553 |
|
\begin{figure} |
554 |
|
\centering |
559 |
|
their body-fixed frames.} \label{oopseFig:gofr} |
560 |
|
\end{figure} |
561 |
|
|
574 |
– |
Due to the fact that the selected StuntDoubles from two selections |
575 |
– |
may be overlapped, {\tt StaticProps} performs the calculation in |
576 |
– |
three stages which are illustrated in |
577 |
– |
Fig.~\ref{oopseFig:staticPropsProcess}. |
578 |
– |
|
579 |
– |
\begin{figure} |
580 |
– |
\centering |
581 |
– |
\includegraphics[width=\linewidth]{staticPropsProcess.eps} |
582 |
– |
\caption[A representation of the three-stage correlations in |
583 |
– |
\texttt{StaticProps}]{This diagram illustrates three-stage |
584 |
– |
processing used by \texttt{StaticProps}. $S_1$ and $S_2$ are the |
585 |
– |
numbers of selected stuntdobules from {\tt -{}-sele1} and {\tt |
586 |
– |
-{}-sele2} respectively, while $C$ is the number of stuntdobules |
587 |
– |
appearing at both sets. The first stage($S_1-C$ and $S_2$) and |
588 |
– |
second stages ($S_1$ and $S_2-C$) are completely non-overlapping. On |
589 |
– |
the contrary, the third stage($C$ and $C$) are completely |
590 |
– |
overlapping} \label{oopseFig:staticPropsProcess} |
591 |
– |
\end{figure} |
592 |
– |
|
562 |
|
The options available for {\tt StaticProps} are as follows: |
563 |
|
\begin{longtable}[c]{|EFG|} |
564 |
|
\caption{StaticProps Command-line Options} |
621 |
|
select different types of atoms is already present in the code. |
622 |
|
|
623 |
|
For large simulations, the trajectory files can sometimes reach |
624 |
< |
sizes in excess of several gigabytes. In order to effectively |
625 |
< |
analyze that amount of data. In order to prevent a situation where |
626 |
< |
the program runs out of memory due to large trajectories, |
627 |
< |
\texttt{dynamicProps} will estimate the size of free memory at |
628 |
< |
first, and determine the number of frames in each block, which |
660 |
< |
allows the operating system to load two blocks of data |
624 |
> |
sizes in excess of several gigabytes. In order to prevent a |
625 |
> |
situation where the program runs out of memory due to large |
626 |
> |
trajectories, \texttt{dynamicProps} will estimate the size of free |
627 |
> |
memory at first, and determine the number of frames in each block, |
628 |
> |
which allows the operating system to load two blocks of data |
629 |
|
simultaneously without swapping. Upon reading two blocks of the |
630 |
|
trajectory, \texttt{dynamicProps} will calculate the time |
631 |
|
correlation within the first block and the cross correlations |