Well-tempered metadynamics applied to Langevin field-theoretic simulations of diblock copolymers on GPUs
See https://www.tbeardsley.com/projects/lfts/wtmd for a detailed discussion of this project.
GSL - GNU Scientific Library (https://www.gnu.org/software/gsl/)
CUDA Toolkit (https://developer.nvidia.com/cuda-toolkit/)
Two methods of compiling the program are available:
- comp.sh
A simple bash script to create a 'build' directory containing the compiled program code: wtmd-lfts-gpu.
On a Linux system, run the bash script from the top directory via:
sh comp.sh
- CMake
CMakeLists.txt specifies the required commands for CMake to create (and run) Makefiles, which create a 'build' directory and compile the program code as: wtmd-lfts-gpu.
From the top directory, run:
cmake -B build
cmake --build build
After compilation the executable file, wtmd-lfts-gpu, resides in the 'build' directory. Two input files are required and must be supplied to the executable at the command line. The first specifies the standard parameters and input fields for a Langevin field-theoretic simulation (L-FTS). The second specifies parameters and input potentials related specifically to performing well-tempered metadynamics (WTMD). Examples of these two files are contained in the 'input_files' folder.
For example, from the top level of the directory tree the program could be run via:
./build/wtmd-lfts-gpu ./input_files/input ./input_files/bias_in
The input_files directory contains example input files that can be supplied to the program from the command line.
Line 1: N NA XN C Ndt isXeN
Line 2: mx my mz Lx Ly Lz
Line 3: n_eq n_st n_smpl save_freq loadType
Lines 4->(M+3): W-(r)
Lines (M+4)->(2M+3): w+(r)
Note: A real-space position r = (x,y,z) corresponds to a mesh point position r_m = (i,j,k), where i=0->mx-1, j=0->my-1 and k=0->mz-1 are integers. The elements of the fields, W-(r) and w+(r), are then written in ascending order of the row-major index: p = mx*(i*my+j)+k.
Parameter | Type | Description |
---|---|---|
N | Integer | Number of monomers in a single polymer chain |
NA | Integer | Number of monomers in the A-block of a polymer chain |
XN | Double | Interaction strength between A anD B-type monomers |
C | Double | Square root of the invariant polymerisation index, Nbar |
Ndt | Double | Size of the time step in the Langevin update of W-(r) |
isXeN | Integer | Whether the parameter XN is in terms of bare (isXeN=0) or effective (isXeN=1) chi |
mx, my, mz | Integers | Number of mesh points in the x, y, and z dimensions of the simulation box |
Lx, Ly, Lz | Doubles | Dimensions of the simulation box (in units of the polymer end-to-end length, R0) in the x, y, and z dimensions |
n_eq | Integer | Number of langevin steps performed to equilibrate the system |
n_st | Integer | Number of langevin steps performed after equilibration has ended, during which statistics are sampled |
n_smpl | Integer | Number of steps between samples being taken in the statistics period |
save_freq | Integer | Number of steps between saving outputs to file |
loadType | Integer | Whether to load the W-(r) and w+(r) fields from the proceeding file lines (loadType=1), start from a disordered state (loadType=0) or start from a (300) lamellar phase (loadType=2) |
M | Integer | Total number of mesh points (M = mx*my*mz), such that the proceeding 2*M lines of the file can hold W-(r) and w+(r) fields to load |
Line 1: ell kc sigma_Psi DT Psi_min mPsi dPsi update_freq read_bias
Lines 2->(mPsi+1): Psi u(Psi) up(Psi) I0(Psi) I1(Psi)
Parameter | Type | Description |
---|---|---|
ell | Double | Constant, l, used in the definition of the order parameter |
kc | Double | Wavevector cutoff (constant) in order parameter |
sigma_Psi | Double | Width of Gaussians added to the bias potential |
DT | Double | Rate at which the amplitude of Guassians is reduced |
Psi_min | Double | Lowest value of Psi for which the bias potential is collected |
mPsi | Integer | Total number of mesh points covering the range of Psi being investigated |
dPsi | Double | Distance between adjacent mesh points in Psi |
update_freq | Integer | Number of Langevin steps between updates of the bias potential |
read_bias | Integer | Flag indicating whether an initial bias potential should be read from file (read_bias=1) or not (read_bias=0) |
Note: Lines 2->(mPsi+1) are only read if read_bias=1, otherwise the bias potential starts with all elements equal to zero.
The state of the W-(r) and w+(r) fields at simulation step number <step_number> during the equilibration period. First three lines are simulation parameters so it can be used as an input file.
The state of the W-(r) and w+(r) fields at simulation step number <step_number> during the statistics gathering period. First three lines are simulation parameters so it can be used as an input file.
The state of the phi-(r) and phi+(r) fields at simulation step number <step_number> during the equilibration period.
The state of the phi-(r) and phi+(r) fields at simulation step number <step_number> during the statistics gathering period.
Output file in the same format as the WTMD input file, containing the current state of the bias potential after step_number Langevin steps in the statistics gathering phase.
The tools folder in the root directory contains a simple script for taking the first M lines of a w_<..><step_number> or phi<..>_<step_number> output file from the simulation, and creating a .vtk file that can be loaded into Paraview for visualisation as a volume plot. Note that the first M lines are used as they correspond to the W-(r) or phi-(r) fields, which are usually the ones of interest. The script could easily be edited to use lines M+1 to 2M in order to plot w+(r) or phi+(r) instead.
The script can be run from the command line as follows:
sh make_vtk.sh <path_to_file_to_visualise> <mx> <my> <mz>
where mx, my and mz are the number of grid points in the x, y and z-dimensions of the file being visualised.
The script's output file name will be the same as <path_to_file_to_visualise>, but with a .vtk extension.