| 1 |
|
\appendix |
| 2 |
|
\chapter{\label{chapt:oopse}Object-Oriented Parallel Simulation Engine} |
| 3 |
|
|
| 4 |
< |
Designing object-oriented software is hard, and designing reusable |
| 5 |
< |
object-oriented scientific software is even harder. Absence of |
| 6 |
< |
applying modern software development practices is the bottleneck of |
| 7 |
< |
Scientific Computing community\cite{Wilson2006}. For instance, in |
| 8 |
< |
the last 20 years , there are quite a few MD packages that were |
| 9 |
< |
developed to solve common MD problems and perform robust simulations |
| 10 |
< |
. However, many of the codes are legacy programs that are either |
| 11 |
< |
poorly organized or extremely complex. Usually, these packages were |
| 12 |
< |
contributed by scientists without official computer science |
| 13 |
< |
training. The development of most MD applications are lack of strong |
| 14 |
< |
coordination to enforce design and programming guidelines. Moreover, |
| 15 |
< |
most MD programs also suffer from missing design and implement |
| 16 |
< |
documents which is crucial to the maintenance and extensibility. |
| 17 |
< |
Along the way of studying structural and dynamic processes in |
| 18 |
< |
condensed phase systems like biological membranes and nanoparticles, |
| 19 |
< |
we developed and maintained an Object-Oriented Parallel Simulation |
| 20 |
< |
Engine ({\sc OOPSE}). This new molecular dynamics package has some |
| 21 |
< |
unique features |
| 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 |
| 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, |
| 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 |
| 63 |
< |
Sec.~\ref{appendixSection:appendixSection:DynamicProps}), |
| 64 |
< |
\texttt{Dump2XYZ} (see |
| 70 |
< |
Sec.~\ref{appendixSection:appendixSection:Dump2XYZ}), \texttt{Hydro} |
| 71 |
< |
(see Sec.~\ref{appendixSection:appendixSection:hydrodynamics}) |
| 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}. |
| 66 |
|
|
| 67 |
|
\begin{figure} |
| 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: |
| 98 |
< |
\begin{enumerate} |
| 99 |
< |
\item The \emph{name} that is commonly used for the pattern. Good pattern names form a vocabulary for |
| 100 |
< |
discussing conceptual abstractions. a pattern may have more than one commonly used or recognizable name |
| 101 |
< |
in the literature. In this case it is common practice to document these nicknames or synonyms under |
| 102 |
< |
the heading of \emph{Aliases} or \emph{Also Known As}. |
| 103 |
< |
\item The \emph{motivation} or \emph{context} that this pattern applies |
| 104 |
< |
to. Sometimes, it will include some prerequisites that should be satisfied before deciding to use a pattern |
| 105 |
< |
\item The \emph{solution} to the problem that the pattern |
| 106 |
< |
addresses. It describes how to construct the necessary work products. The description may include |
| 107 |
< |
pictures, diagrams and prose which identify the pattern's structure, its participants, and their |
| 108 |
< |
collaborations, to show how the problem is solved. |
| 109 |
< |
\item The \emph{consequences} of using the given solution to solve a |
| 110 |
< |
problem, both positive and negative. |
| 111 |
< |
\end{enumerate} |
| 112 |
< |
|
| 113 |
< |
As one of the latest advanced techniques emerged from |
| 114 |
< |
object-oriented community, design patterns were applied in some of |
| 115 |
< |
the modern scientific software applications, such as JMol, {\sc |
| 116 |
< |
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 |
> |
List.~\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 |
|
|
| 148 |
– |
The corresponding implementation is |
| 149 |
– |
|
| 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 |
|
|
| 163 |
– |
Since constructor is declared as protected, a client can not |
| 164 |
– |
instantiate IntegratorFactory directly. Moreover, since the member |
| 165 |
– |
function getInstance serves as the only entry of access to |
| 166 |
– |
IntegratorFactory, this approach fulfills the basic requirement, a |
| 167 |
– |
single instance. Another consequence of this approach is the |
| 168 |
– |
automatic destruction since static data are destroyed upon program |
| 169 |
– |
termination. |
| 143 |
|
|
| 144 |
|
\subsection{\label{appendixSection:factoryMethod}Factory Method} |
| 145 |
|
|
| 151 |
|
createIntegrator member function) creates products based on the |
| 152 |
|
identifier (see List.~\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 |
> |
List.~\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 |
|
|
| 492 |
|
and other atoms of type $B$, $g_{AB}(r)$. {\tt StaticProps} can |
| 493 |
|
also be used to compute the density distributions of other molecules |
| 494 |
|
in a reference frame {\it fixed to the body-fixed reference frame} |
| 495 |
< |
of a selected atom or rigid body. |
| 495 |
> |
of a selected atom or rigid body. Due to the fact that the selected |
| 496 |
> |
StuntDoubles from two selections may be overlapped, {\tt |
| 497 |
> |
StaticProps} performs the calculation in three stages which are |
| 498 |
> |
illustrated in Fig.~\ref{oopseFig:staticPropsProcess}. |
| 499 |
> |
|
| 500 |
> |
\begin{figure} |
| 501 |
> |
\centering |
| 502 |
> |
\includegraphics[width=\linewidth]{staticPropsProcess.eps} |
| 503 |
> |
\caption[A representation of the three-stage correlations in |
| 504 |
> |
\texttt{StaticProps}]{This diagram illustrates three-stage |
| 505 |
> |
processing used by \texttt{StaticProps}. $S_1$ and $S_2$ are the |
| 506 |
> |
numbers of selected stuntdobules from {\tt -{}-sele1} and {\tt |
| 507 |
> |
-{}-sele2} respectively, while $C$ is the number of stuntdobules |
| 508 |
> |
appearing at both sets. The first stage($S_1-C$ and $S_2$) and |
| 509 |
> |
second stages ($S_1$ and $S_2-C$) are completely non-overlapping. On |
| 510 |
> |
the contrary, the third stage($C$ and $C$) are completely |
| 511 |
> |
overlapping} \label{oopseFig:staticPropsProcess} |
| 512 |
> |
\end{figure} |
| 513 |
|
|
| 514 |
|
There are five seperate radial distribution functions availiable in |
| 515 |
|
OOPSE. Since every radial distrbution function invlove the |
| 554 |
|
\end{description} |
| 555 |
|
|
| 556 |
|
The vectors (and angles) associated with these angular pair |
| 557 |
< |
distribution functions are most easily seen in the figure below: |
| 557 |
> |
distribution functions are most easily seen in |
| 558 |
> |
Fig.~\ref{oopseFig:gofr} |
| 559 |
|
|
| 560 |
|
\begin{figure} |
| 561 |
|
\centering |
| 566 |
|
their body-fixed frames.} \label{oopseFig:gofr} |
| 567 |
|
\end{figure} |
| 568 |
|
|
| 578 |
– |
Due to the fact that the selected StuntDoubles from two selections |
| 579 |
– |
may be overlapped, {\tt StaticProps} performs the calculation in |
| 580 |
– |
three stages which are illustrated in |
| 581 |
– |
Fig.~\ref{oopseFig:staticPropsProcess}. |
| 582 |
– |
|
| 583 |
– |
\begin{figure} |
| 584 |
– |
\centering |
| 585 |
– |
\includegraphics[width=\linewidth]{staticPropsProcess.eps} |
| 586 |
– |
\caption[A representation of the three-stage correlations in |
| 587 |
– |
\texttt{StaticProps}]{This diagram illustrates three-stage |
| 588 |
– |
processing used by \texttt{StaticProps}. $S_1$ and $S_2$ are the |
| 589 |
– |
numbers of selected stuntdobules from {\tt -{}-sele1} and {\tt |
| 590 |
– |
-{}-sele2} respectively, while $C$ is the number of stuntdobules |
| 591 |
– |
appearing at both sets. The first stage($S_1-C$ and $S_2$) and |
| 592 |
– |
second stages ($S_1$ and $S_2-C$) are completely non-overlapping. On |
| 593 |
– |
the contrary, the third stage($C$ and $C$) are completely |
| 594 |
– |
overlapping} \label{oopseFig:staticPropsProcess} |
| 595 |
– |
\end{figure} |
| 596 |
– |
|
| 569 |
|
The options available for {\tt StaticProps} are as follows: |
| 570 |
|
\begin{longtable}[c]{|EFG|} |
| 571 |
|
\caption{StaticProps Command-line Options} |
| 628 |
|
select different types of atoms is already present in the code. |
| 629 |
|
|
| 630 |
|
For large simulations, the trajectory files can sometimes reach |
| 631 |
< |
sizes in excess of several gigabytes. In order to effectively |
| 632 |
< |
analyze that amount of data. In order to prevent a situation where |
| 633 |
< |
the program runs out of memory due to large trajectories, |
| 634 |
< |
\texttt{dynamicProps} will estimate the size of free memory at |
| 635 |
< |
first, and determine the number of frames in each block, which |
| 664 |
< |
allows the operating system to load two blocks of data |
| 631 |
> |
sizes in excess of several gigabytes. In order to prevent a |
| 632 |
> |
situation where the program runs out of memory due to large |
| 633 |
> |
trajectories, \texttt{dynamicProps} will estimate the size of free |
| 634 |
> |
memory at first, and determine the number of frames in each block, |
| 635 |
> |
which allows the operating system to load two blocks of data |
| 636 |
|
simultaneously without swapping. Upon reading two blocks of the |
| 637 |
|
trajectory, \texttt{dynamicProps} will calculate the time |
| 638 |
|
correlation within the first block and the cross correlations |