Showing posts with label LAMMPS. Show all posts
Showing posts with label LAMMPS. Show all posts

Dec 16, 2015

How to use Moltemplate on Windows OS systems

Moltemplate (http://www.moltemplate.org/) is a powerful tool for configuring molecules and assigning force field parameters.
However, its use on Windows OS is somewhat tricky.

1. Install Cygwin (https://cygwin.com/install.html).  Installation of required packages + python should be good enough.

2. Copy all Moltemplate files to C:\cygwin64\home\moltemplate

3. Open "C:\cygwin64\home\username\.bash_profile" in a text editor.  Add a new PATH (in yellow) to a section "# Set PATH so it includes user's private bin if it exists".  For example,

# Set PATH so it includes user's private bin if it exists
# if [ -d "${HOME}/bin" ] ; then
   PATH="/bin/:/home/moltemplate/"
# fi

In Cygwin console (terminal), we can check if the PATH is correctly set by typing "echo $PATH"

5. Place examples (http://www.moltemplate.org/) in C:\cygwin64\home\moltemplate\examples

6. In Cygwin command window (console or teminal), navigate an example folder
(e.g., cd /home/moltemplate/examples/all_atom_examples/force_field_explicit/waterSPCE+Na+Cl/moltemplate_files)

7. In Cygwin command window, type:

moltemplate.sh  -atomstyle "full"  system.lt
or
moltemplate.sh  -xyz  system.xyz  -atomstyle "full"  system.lt
(This will use a premade xyz configuration of system, e.g., system.xyz).

LAMMPS input and data files will be created.  (e.g., system.in and system.data)

Dec 10, 2014

LAMMPS - Parallel computing on a multi-core Windows flatform

LAMMPS, a molecular dynamics simulator supports parallel computing.
To use such parallel function, we need to install MPI. (MPICH2, openMPI, or MS-MPI)


For Windows 7,
MPICH2 can be downloaded at  http://www.mpich.org/downloads/
openMPI can be downloaded at  https://www.open-mpi.org/software/
MS-MPI can be downloaded at  http://www.microsoft.com/en-au/download/details.aspx?id=36045


After installing,
1. two excutable files (mpiexec.exe and smpd.exe) need to be copied to LAMMPS bin folder (with lmp_serial.exe and lmp_mpi.exe).
2. open a command prompt (cmd.exe) as an administrator and then type the following commands in sequence.
     smpd -install
     mpiexec -remove
     mpiexec -register     (set up "username" and "password")
     mpiexec -validate     (it should return "SUCCESS")
     smpd -status     (it should return "smpd running on 'hostname')


Now, we are ready to run parallel computing.
When running, "-localonly '# of processors' " option should be used.
mpiexec -localonly 4 lmp_mpi < example.in

To make sure, just compare results of both serial and parallel simulations using same input script.
e.g.,
lmp_serial < example.in
mpiexec -localonly 4 lmp_mpi < example.in



Apr 27, 2011

rearranging atoms crossed a periodic boundary

To rearrange atoms that crossed a periodic boundary:

1) load trajactory file (xyz, pdb, etc) in VMD.
2) in the VMD main console,
       pbc unwrap -all

or
2) graphics menu --> representations --> periodic --> +x, +y, +z

Apr 22, 2011

An easy way to create initial molecular system for computer simulation

Creating a single molecular structure is relatively easy if we use a molecule editor (e.g, Avogadro, Materials Studio, etc).
However, a molecular system consisting of many molecules cannot be easily prepared by those editors.
"Packmol" is a good software for readily creating such a large system.
or  http://leandro.iqm.unicamp.br/packmol/versionhistory/


1. Install "Packmol" as instructed. (it can easily be built in Cygwin64 console.)
2. Prepare component molecules in pdb, xyz, etc file format.
    (component molecules can be DPD structure.)
3. Make an input script 
4. Run "packmol < filename.inp"



An example Packmol input script is below:


# Every atom from diferent molecules will be far from each other at least 2.0 Angstroms in the system.
tolerance 2.0 

# Coordinate file types will be in pdb format (keyword not required for pdb file format, but required for tinker, xyz or moldy).
filetype xyz

# The output configuration filename
output 100water_5Na_5Cl.xyz


# The first three numbers are the minimum x, y, z coordinates for this molecules, the last three are maximum coordinates. 

structure Na.xyz
  number 5
  inside box 0. 0. 0. 20. 20. 20.
end structure

structure Cl.xyz
  number 5
  inside box 0. 0. 0. 20. 20. 20.
end structure 

structure water.xyz 
  number 100
  inside box 0. 0. 0. 20. 20. 20.
# inside box  Xmin Ymin Zmin  Xmax Ymax Zmax
# inside sphere  10.0 10.0 15.0 8.0
# inside sphere  a b c d  (a,b,c,d in a sphere equation, (x-a)^2 + (y-b)^2 + (z-c)^2 - d^2 = 0,  d is the diameter)
# inside cylinder  0.0 0.0 0.0  1.0 0.0 0.0  5.0  10.0    
# inside cylinder  x1 y1 z1  x2 y2 z2  d  l  (direction_of_line_in_vector_(x1 y1 z1  x2 y2 z2),  distance_to_the_line_(d),  length_of_cylinder_(l))

end structure

Apr 9, 2011

How to debug LAMMPS' run

When error "Segmentation Fault" pops up, we need to debug the run because many reasons can cause the error.


To find the location of the segmentation fault, you can just run lammps with the help of a debugger, e.g. gdb.

gdb  /path/lmp_openmpi

then on the gdb prompt you type:

run -in filename.in

and then wait for the segmentation fault.  When it happens, you can type:

where

and you get a stack trace and that will indicate the location of where the segmentation fault happens.




The alternative to this is to generate a core dump:

first type: ulimit -c unlimited

then run lmp_openmpi as usual. (lmp_openmpi -in filename.in)
after it crashed, you should see a file core.###. again, you can use gdb to investigate:

gdb /path/lmp_openmpi  /path/core.###

and then:

where

and you get a stack trace again, telling you the location (function name) of the problem.
and then you double check with the current version of lammps.



Apr 6, 2011

How to generate LAMMPS data file with force field parameters

To make LAMMPS data file using pdb file in VMD,

1. load pdb file (or any molecule configuration file) in VMD

2. in VMD command line, type
topo writelammpsdata filename type
# type : full, atomic, etc..

3. a data file with filename is created in VMD folder

The "topotools" is a plugin for VMD.  https://sites.google.com/site/akohlmey/software/topotools




To make LAMMPS data file with force field parameters, "msi2lmp", a LAMMPS tool (/tools/msi2lmp/) can be used.

1. build msi2lmp
make   in /tools/msi2lmp/src/

2. msi2lmp.exe, force field file (e.g., cvff.frc), car and mdf files should be in same directory.
msi2lmp.exe rootname -class I -frc force_field_name
# rootname.cat
# rootname.mdf
# -class I (e.g, cvff), -class II (e.g., CFFx)
# -frc cvff   (cvff.frc)

3. rootname.lammps05 will be generated.

Jan 22, 2011

installation problems on CFLAGS, CPPFLAGS, and LDFLAGS

When installing LAMMPS and ESPResSo, the softwares do not find fftw path automatically.
So, adding the fftw path to the default path (.bashrc and/or .bash_profile) is necessary.


CFLAGS=-I/usr/global/fftw/2.1.5/gnu/include
CPPFLAGS=-I/usr/global/fftw/2.1.5/gnu/include
LDFLAGS=-L/usr/global/fftw/2.1.5/gnu/lib
export CFLAGS CPPFLAGS LDFLAGS


For information, ESPResSo can use fftw 3 but LAMMPS use fftw 2 at present (Jan 2011).


.bashrc is loaded when using remote desktop connection (then, terminal).
.bash_profile is loaded when connecting with telnet or SSH secure shell.