How to prepare files using moltemplate
How to Use moltemplate
Below are the basic steps for working with Moltemplate. I’ll explain one of the examples below:
If you haven’t worked with Moltemplate recently, get system.lt and urea.lt to the test directory.
Run the following command for lammps run:
moltemplate.sh system.lt
You can get rid of unnecessary lines in the file by typing the following command:
cleanup_moltemplate.sh
You will get these files after running the previous commands:
system.in |
lammps input file |
system.data |
lammps data file |
system.in.init |
force field functions |
If you finish the urea sample, you can continue with the actual data.
Step 1
Get the file from ovito with mass, charges, and bond information (in the format of a .data file). If you have other information, you can delete it now. Then type:
ltemplyfy.sh ovitofilename > outputfilename (ltemplyfy.sh urea.data > urea.lt)
For example:
ltemplyfy.sh urea.data > urea.lt
Step 2
Check the urea.lt file or the output file you made. You may have to modify several things. If you don’t see a part that I will mention, skip that part.
Add import “gaff.lt” before write_once(“In Init”) {.
Add Urea inherits GAFF { on the next line after the import “gaff.lt”.
Add another closed curly bracket } at the end of the file.
If you have a unique name for the atom type that is not used in GAFF, make sure you change the name in the Data Atoms section. For example, if you have n1 and n2, you can keep the name in Data Masses, but you have to have the right name such as n in Data atom section. Check useful commands shown below.
Remove bond type (such as @bond:type1).
Change “Data Bonds” to “Data Bond List”.
Check the atom information. If it says type##, you have to change the name of the type to the corresponding one. If you change this, you also have to change @atom: to the new name. Also you need to change atom in Data Bond List.
In Data Atoms section, if you don’t have $mol section or the value for this is the same for the whole system, you have to check the input data. Most likely you need to go to Ovito and assign molecule data. Basically, you need to do clustering and go to compute property > molecule identifier > cluster. More details are in How to use Ovito.
If you see angle data or some others after Bond information, remove that information now.
module load anaconda3/2020.07
Change system.lt’s first line to whatever the input file, change the cell box size.
Run:
moltemplate.sh system.lt
Check system.data to make sure it ran.
Clean up the code by typing:
cleanup_moltemplate.sh
If you want to change the atom type, do it now. Make sure you change it to the right name.
Change the n2 in the Atom List to the corresponding name.
Use this file as a standard.
When you use it in LAMMPS, you need to have system.data, system.in.init, and system.in.settings in the running directory.
You need to modify urea.in.settings if you change the atom information. For instance, if you added n2, you should have a line for that too.
Also, change the atom type from 4 to 5 for urea in system.data.
Useful Commands When Using Moltemplate in Vim:
:/@bond:type3 <-- highlight the words type3.
:%s///g <-- delete the highlighted words.
%s/@atom:n1 /@atom:n /g <-- replace all @atom:n1 in the file to @atom:n