Polymer Monte Carlo (PMC)

v0.1

Introduction

PMC is a C++ class library for continuum Monte Carlo (MC) and Molecular Dynamics (MD) simulations of molecular liquids. It provides a framework for building simulations by combining core classes that contain elements common to all MC and/or MD simulations with an extensible hierarchy of classes that represent optional elements.

Usage

PMC is designed as a library of building blocks, rather than a monolithic program. In this framework, a complete simulation is represented by a McSystem or MdSystem object. McSystem and MdSystem are abstract base classes for Monte Carlo and Molecular Dynamics simulations, respectively. Both are derived from the System class, which contains elements needed in either type of simulation.

To construct a complete simulation a user must either write a customized subclass of McSystem or MdSystem, or use one of our examples of such a subclass. The job of such a user-defined subclass is to implement a mechanism to add objects to the simulation that represent optional elements, i.e., elements that are needed in some simulations but not others. To create an executable program, a user will also also needs to write (or use one or our examples of) a very short main program, as discussed below.

Examples of user-defined subclasses of McSystem and MdSystem, respectively, are are provided in:

Corresponding main programs are given in example/mc/mc.cpp and example/md/md.cpp.

The main program must create an instance of a user-defined subclass of McSystem or MdSystem, and invoke methods of that object to read the required input files and to run the simulation. The essential lines of of our example program for MC simulation thus look like this:

 int main 
 {
    MyMcSystem sys;
    
    \\ Read the parameter file from standard input
    sys.read(stdin)

    \\ Run the simulation
    sys.run()

 }
The read() method reads a parameter file, which in this example is read from standard input. All the initialization required to set up a simulation is done within the read() method. Among other things, the read() method invokes a method to read a separate configuration file, using a file path that is specified in the parameter file.

The parameter file contains all the parameters required by a simulation, including both physical parameters such as the temperature and potential energy parameters, and instructions for the simulation algorithm, such as the choice of Monte Carlo moves to be used for a Monte Carlo simulation or the choice of time step for an MD simulation.

The configuration file contains the current configuration of the system, including the size and dimensions of the simulation box, all of the particle positions, and the number of molecules of each species.

Customization: Species, Moves, and Diagnostics

Optional elements of an MC or MD simulation are represented by subclasses of the following three abstract base classes: The class library currently contains a limited number of subclasses of each base class, in the src/species, src/mcmove, and src/diagnostic directories. A user may want or need to write more to solve specific problems beyond those for which we have used PMC. Our example classes MyMcSystem and MyMdSystem provide access to all of the subclasses of Species, McMove, and Diagnostic that are provided as part of the class library.

Access to a subclass of Species, McMove, or Diagnostic is provided by including the subclass header in the definition of a user-defined subclass of McSystem or MdSystem, and by adding a few lines of code to one of three factory functions, named speciesFactory, mcMoveFactory, and diagnosticFactory. Each of these factory functions is a virtual function that takes a subclass name string as a parameter and (if the class name is recognized) returns a base class pointer to a new instance of the desired subclass. The factory functions are invoked by methods of System and McSystem methods that read the input parameter and configuration files, and are used to create new instances of classes whose names are specified in an input file. The implementation of each factory function thus defines a set of subclasses of Species, McMove, or Diagnostic whose names will be recognized if encountered in the appropriate input file. The content of the actual input files defines what objects of will actually be instantiated and used in a simulation.

The parameter file for an MC simulation contains a list of what Monte Carlo moves that should be used in the simulation. Each Monte Carlo moves is represented by a section of the file that starts with the name of the corresponding subclass of McMove, followed by any parameters required by that type of move (e.g., the maximum displacement for a simple single particle displacement move). To add a specified Monte Carlo move to a simulation, while reading that part of the parameter file, the McSystem::read(FILE *) method reads the name of a subclass of McMove, and then passes it to the virtual mcmoveFactory() method. If the mcmoveFactory() method recognizes the McMove subclass name, creates an object of that subclass and returns a pointer to the new object. The McSystem read() method then reads the probability per elementary step that the move will be executed, and then (indirectly) invokes the read() method of the newly created McMove object to read in whatever parameters that type of Monte Carlo move may need.

The parameter file format for both MC and MD simulations also contains an analogous (possibly empty) list of Diagnostic objects that should be added to the simulation. Each of these is also identified by a class name, followed by whatever parameters are required by that type of Diagnostic object. A Diagnostic object represents a file output and/or data analysis operation that must be carried out at a specified frequency, specified as a number of elementary MC moves or MD time steps. A Diagnostic may either dump data to a file or carry out some on-the-fly statistical analysis (e.g., evaluting an average value for a specific quantity) and output results at the end of the simulation, or both.

The configuration file for a MC or MD simulation contains a similar sequence of sections that represent different molecular species. Each of these is identified by the name of a subclass of Species, followed by the number of molecules of that species in the System, and by any structural parameters required to define the structure of the species (i.e., the number of particles per chain in a linear homopolymer species).

Potential Energy Functions

It would be convenient to use a similar mechanism to choose from among various possible functional forms for nonbonded and bond interactions at run time. For reasons of efficiency, however, we have chosen not to provide this. The classes used to calculate interaction energies and forces are instead non-polymorphic classes that are chosen and linked at compile time. By avoiding virtual functions, this allows to inline the functions used to evaluate energies and forces in the inner loops of the program, thus avoiding the overhead with function calls, as well as the additional cost of virtual functions.

To make it easy to recompile a simulation with a different choice of potentials, the classes that represent the nonbonded potential and the covalent bond potential are referred to throughout the core classes via typedefs named PairPotential and BondPotential, which can be redefined. These typedefs are defined in the header files src/base/PairPotential.h and src/base/BondPotential.h, which also include the header files for the actual pair and bond potential classes (e.g., LJPair and HarmonicBond). See the documentation for these typedefs for an explanation of how to recompile with different potential classes by changing a few lines in each of these header files.

Compiling

The program is written in standard C++, and has no external dependencies. It was developed using the gcc compiler in a linux environment. To compile all of the source code, including the example simulation programs: To clean up all of the *.o files and start over, enter make clean from the same directory.

This documentation is generated by dOxygen. To regenerate all of the API documentation from comments in the source code, enter the command

    > make doc
 
from within the src directory. The html documentation is deposited in the doc/api directory. Entering 'make cleandoc' from the src directory will remove all the html documentation.

Implemented Features

Though the library design is quite general, the code has thus far only been used for NVT simulations of coarse-grained models of polymer liquids. The features we have implemented are, for the most part, those necessary for this class of problems. Currently implemented features include: The library does not yet supply classes for bending or torsion potentials, or Coulomb interactions.

Credits

Development of PMC began in Jan. 2008, using a procedural C code developed in Juan de Pablo's group at the University of Wisconsin as a starting point. As of Aug. 2008, the University of Wisconsin group is also collaborating with us on further development of PMC.

Contributors:

Morse Group Home Page


Generated on Fri Oct 31 10:28:18 2008 for Polymer Monte Carlo (PMC) by  doxygen 1.4.7