%This manual (like moltemplate) is under development.
\tableofcontents
%Additionally, several working examples of molecules created
%with moltemplate can be found in the ``examples/'' subdirectory
%(which is distributed with moltemplate).
%These were created to supplement the moltemplate documentation.
\section{Introduction}
Moltemplate is a general molecule builder and force-field database system for LAMMPS. A simple file format has been created to store molecule definitions and force-fields (the LAMMPS-template format, “LT”).
LT files are templates containing \textit{all} of the text relevant to a particular molecule (including coordinates, bond-topology, angles, force-field parameters, constraints, groups and fixes). Moltemplate can then duplicate the molecule, customize it, and use it as a building-block for constructing larger, more complex molecules. (These molecules can be used to build even larger molecules.) Once built, individual molecules and subunits can be customized (atoms and bonds, and subunits can be inserted, moved, deleted and/or replaced).
Popular force-fields such as AMBER GAFF and OPLS-AA have been converted into LT format, allowing users to quickly create molecules using moltemplate. (With help, more popular force-fields can be converted.) This way moltemplate users can build a molecule by specifying only a list of atoms in the molecule and the bonds connecting them. End-users are not required to manually specify all of the force-field parameters. However they still have the freedom to easily customize individual interactions when needed.
%or generate all of its angle, dihedral, improper interactions manually.
Moltemplate is extremely flexible. It supports all LAMMPS force-field styles and nearly all atom-styles (now and in the future).
% OLD VERSION
%Moltemplate is a cross-platform text-based molecule builder for LAMMPS. It is typically used for building coarse-grained toy molecular models. Moltemplate users have access to (nearly) all of the standard and non-standard (custom, user-created) force-field and features available in LAMMPS.
%
%\textit{(Although optimized for LAMMPS, moltemplate is a general text manipulation tool which, in principle, could be used to generate topology and force-field files for other simulation programs. Please email \includegraphics[height=0.3cm]{author_email.png} if you want to attempt this.)}
%
%A file format has been created to store molecule definitions (the LAMMPS-template format, ``LT''). Typical ``.LT'' files contain atom coordinates, topology data (bonds), LAMMPS force-field data, and other LAMMPS settings (such as group definitions, fixes, and user-defined input files) for a type of molecule (or a molecular subunit). Molecules can be copied, combined, and linked together to define new molecules. (These can be used to define larger molecules.)
%%Unlimited levels of object composition, nesting, and inheritance are supported.)
%Once built, individual molecules and subunits can be customized (atoms and bonds, and subunits can be moved, deleted and replaced).
Moltemplate requires the Bourne-shell, and a recent version of python (2.7 or 3.0 or higher), and can run on OS X, linux, or windows (if a suitable shell environment has been installed).
\textbf{A substantial amount of memory is needed} to run moltemplate.
For example, building a system of 1000000 atoms typically requires
between 3 and 12 GB of \textit{available} memory.
(This depends on the number of bonds, molecules, and angular interactions.
See section \ref{sec:limitations} for details.)
%Memory requirements are discussed in section \ref{sec:limitations}.
%Moltemplate is a text-manipulation tool for generating
%input files for molecular dynamics simulation programs.
%Moltemplate has been optimized for constructing input files for LAMMPS.
%from constituent parts.
%Molecules are stored in a hierarchical,
%object-oriented,
%template-based file format (``.LT'').
% %using an object-oriented style
% %which can mimic many popular molecular file formats.
% %such as PDB, amber TOP, Gromacs TOP,
% %PSF files, and some limited xplor parameter files.
% \subsubsection*{Using ``lttree.py'' instead of ``moltemplate.sh''}
% The format of an ``.LT'' file closely mimics the syntax in
% current LAMMPS data and input script files (as of early 2013).
% However LAMMPS file formats are constantly changing
% as users add their own custom features to LAMMPS.
% (In addition, there are some currently known limitations of
% moltemplate.sh, which are discussed in section \ref{sec:limitations}.)
% %However this file format must be flexible enough
% %to handle potentially radical syntax changes in the future.
% %End users who add new features to LAMMPS may also modify the syntax
% %of these input files, and will likely introduce new file formats.
% Consequently, we also provide several simple python scripts:
% %(which should remain useful when/if moltemplate.sh breaks)
% ``ttree.py'', ``lttree.py'', and ``nbody\_by\_type.py''.
% %\begin{list}
% %\item
% %``ttree.py'', is a general text manipulation
% %tool which prints out the text contained in the
% %``write()'' and ``write\_once()'', commands in an LT file,
% %and substitutes numerical values into the \$ and \@ variables
% %contained inside.
% %\item
% %``lttree.py'' is a variant of ``ttree.py''
% % %understand LAMMPS atom\_style syntax and
% %which also generates atomic coordinates.
% %(It process the ``.move()'' and ``.rot()'' commands.)
% %\item
% %``nbody\_by\_type.py'' is a utility which generates
% %many-body bonded interactions between atoms automatically,
% %according to the atom and bond type.
% %(It processes the ``Data Angles By Type'',
% %``Data Dihedrals By Type'', and ``Data Impropers By Type'' sections.)
% %\end{list}
% The ``ttree.py'' program is a general text manipulation tool which
% should continue to work in the distant future,
% even if the LAMMPS syntax changes radically, and ``moltemplate.sh'' breaks.
% (``ttree.py'' is nearly identical to and supports all the
% command line options used by ``moltemplate.sh'',
% with the exception of ``-pdb'', ``-xyz'', and ``-raw''.)
% %However this tool is intentionally simple and ignorant about LAMMPS.
% %This allows programmers to add features to LAMMPS without ever
% %breaking the ``.LT'' file format.
% %(although you may have to sacrifice some convenience
% %that using moltemplate.sh provides).
% A tutorial for using these programs
% is provided in appendix \ref{sec:ttree}.
\section{Installation}
\subsection*{Obtaining Moltemplate}
\textit{If you don't already have moltemplate},
the most up-to-date version can be downloaded at
\url{http://www.moltemplate.org}
If you obtained moltemplate as a .tar.gz file,
(as opposed to github or pip), you can unpack it using:
\begin{verbatim}
tar -xzvf moltemplate_2017-8-22.tar.gz
\end{verbatim}
(The date will vary from version to version.)
Alternately, if you obtained moltemplate bundled with LAMMPS,
then the \textit{``moltemplate''} directory will probably be located
in the \textit{``tools''} subdirectory of your lammps installation.
There are two ways to install moltemplate:
\subsubsection*{Installation Method 1 (pip)}
\textit{If you are familiar with pip}, then run the following command from within outermost directory:
\begin{verbatim}
pip install .
\end{verbatim}
\textit{In order for this to work, this directory should contain a file named ``\textbf{setup.py}''.} (If no such file exists, then either proceed to ``Installation Method 2'' below, or download a newer version of moltemplate.) If you receive an error regarding permissions, then run pip this way instead:
\begin{verbatim}
pip install . --user
\end{verbatim}
Make sure that your default pip install bin directory is in your PATH. (This is usually something like \textapprox/.local/bin/ or \textapprox/anaconda3/bin/. If you have installed anaconda, your PATH should have been updated for you automatically.) Later, you can uninstall moltemplate using:
\begin{verbatim}
pip uninstall moltemplate
\end{verbatim}
\textit{If you continue to run into difficulty}, try installing moltemplate into a temporary virtual environment by installing ``virtualenv'', downloading moltemplate (to ``\textapprox/moltemplate'' in the example below), and running these commands:
\begin{verbatim}
cd ~/moltemplate
virtualenv venv
source venv/bin/activate
pip install .
#(now do something useful with moltemplate...)
\end{verbatim}
You will have to ``run source \textapprox/moltemplate/venv/bin/activate'' beforehand whenver you want to run moltemplate. If all this fails, then try installing moltemplate by manually updating your \$PATH environment variable. Instructions for doing that are included below.
\subsubsection*{Installation Method 2}
Alternatively, you can edit your PATH variable manually to include
the subdirectory where the moltemplate.sh script is located
(typically ``\textapprox/moltemplate/moltemplate/scripts/''), as well as
the directory containing the most of the python scripts (``\textapprox/moltemplate/moltemplate/'').
Suppose the directory where with the README file is named ``moltemplate''
and it is located in your home directory:
If you use the \textbf{bash} shell, typically you would edit your
log back in again for the changes to take effect.}
\subsubsection*{WINDOWS installation suggestions}
You can install both moltemplate and LAMMPS in windows, but you will first need to install the BASH shell environment on your computer. If you are using Windows 10 or later, try installing the "Windows Subsystem for Linux (WSL)"
To use LAMMPS and moltemplate, You will also need to install (and learn how to use) a text editor. (Word, Wordpad, and Notepad will not work.) Popular free text editors which you can safely install and run from within the WSL terminal include: nano, ne, emacs, vim, and jove. (Unfortunately, as of 2017-5-17, graphical unix-friendly text editors such as Atom, VSCode, Notepad++, and sublime won't work with WSL, and may cause file system corruption. Avoid these editors for now. (\url{https://www.reddit.com/r/bashonubuntuonwindows/comments/6bu1d1/since_we_shouldnt_edit_files_stored_in_wsl_with/})
%\pagebreak
\section{Quick reference \textit{(skip on first reading)}}
\section*{
\textit{Note: New users should skip to section \ref{sec:tutorial}}
}
\subsection{Moltemplate commands}
%\begin{table}
\begin{longtable}[h]{l|p{9cm}}
\textbf{command}&\textbf{meaning}
\\
\hline
\hline
\begin{tabular}[t]{l}
\\
\textit{MolType}\textbf{\{}\\
\\
\hspace{0.35cm}\textit{content} ... \\
\\
\textbf{\}}\\
\end{tabular}
&
Define a new type of molecule (or namespace) named \textit{MolType}.
The text enclosed in curly brackets (\textit{content})
typically contains multiple write(), write\_once()
commands to define Atoms, Bonds, Angles, Coeffs, etc...
\textit{(If that molecule type exists already,
then this will append additional \textbf{content} to its definition.)}
\textbf{new} and \textbf{delete} commands can be used
to create or delete molecular subunits \textit{within} this molecule.
(See the \textit{SPCE}, \textit{Monomer}, and \textit{Butane}
molecules, and the \textit{TraPPE} namespace
defined in sections \ref{sec:spce_example}, \ref{sec:2bead},
Allow alternate names for the same variable. This replaces all instances of \textit{oldvariable} with \textit{newvariable}. Both variable names must have a ``@'' prefix. This is typically used to reduce the length of long variables, for example to allow the shorthand ``@atom:C2'' to refer to ``@atom:C2\_bC2\_aC\_dC\_iC''
\\
\hline
\textbf{\#}\textit{commented text}&
All text following a ``\#'' character is treated as a comment and ignored.
\end{longtable}
%\caption{List of moltemplate commands}
%\label{tab:commands}
%\end{table}
%\pagebreak
\subsection{Common \$ and @ variables}
(See section \ref{sec:variables} for details.) \\
\begin{tabular}[h]{l|p{11cm}}
\textbf{variable type}&\textbf{meaning}
\\
\hline
\hline
\$atom:\textit{name}&
A unique ID number assigned to atom \textit{name} in this molecule.
(Note: The \textit{:name} suffix can be omitted if the molecule
in which this variable appears only contains a single atom.)
%(This number is unique even if there are multiple copies of this molecule.)
\\
\hline
@atom:\textit{type}&
A number which indicates an atom's \textit{type}
(typically used to lookup pair interactions.)
\\
\hline
\$bond:\textit{name}&
A unique ID number assigned to bond \textit{name}
(Note: The \textit{:name} suffix can be omitted if the molecule
in which this variable appears only contains a single bond.)
\\
\hline
@bond:\textit{type}&
A number which indicates a bond's \textit{type}
\\
\hline
\$angle:\textit{name}&
A unique ID number assigned to angle \textit{name}
(Note: The \textit{:name} suffix can be omitted if the molecule
in which this variable appears only contains a single angle interaction.)
\\
\hline
@angle:\textit{type}&
A number which indicates an angle's \textit{type}
\\
\hline
\$dihedral:\textit{name}&
A unique ID number assigned to dihedral \textit{name}
(Note: The \textit{:name} suffix can be omitted if the molecule in which
this variable appears only contains a single dihedral-angle interaction.)
\\
\hline
@dihedral:\textit{type}&
A number which indicates a dihedral's \textit{type}
\\
\hline
\$improper:\textit{name}&
A unique ID number assigned to improper \textit{name}
(Note: The \textit{:name} suffix can be omitted if the molecule in which
this variable appears only contains a single improper interaction.)
\\
\hline
@improper:\textit{type}&
A number which indicates an improper's \textit{type}
\\
\hline
\$\textit{mol}\hspace{0.2cm} or \hspace{0.2cm}\$\textit{mol:.}&
This variable refers to the ID number of \textit{this} molecule object.
(See section \ref{sec:spce_example}.
Note: \mbox{\textit{``\$mol''}} is shorthand for \mbox{\textit{``\$mol:.''}})
\\
\hline
\$\textit{mol:}... &
The ID number assigned to the molecule to which this object belongs
(if applicable).
See sections \ref{sec:2beadPeptide},
\ref{sec:ellipsis_mol},
%\ref{sec:paths},
and appendix \ref{sec:adv_variable_syntax}.
\\
\hline
\hline
\multicolumn{2}{p{16.5cm}}{
%Variable operations
\textit{The numbers assigned to each variable are saved in the \textbf{output\_ttree/ttree\_assignments.txt} file}
%See section \ref{sec:output_ttree}.
}
\\
\hline
\hline
\multicolumn{2}{l}{
%Variable operations
\quad\textit{\textbf{Advanced variable usage}}
}
\\
\hline
\textit{\$category}:\textbf{query}()
&
Query the current value of the counter in this \textit{\$category}
without incrementing it.
(The ``\textit{\$category}'' is usually either \textit{\$atom}, \textit{\$bond}, \textit{\$angle}, \textit{\$dihedral}, \textit{\$improper}, or \textit{\$mol}.)
This is useful for counting the number of
atoms, bonds, angles, molecules, etc... created so far.
\\
\hline
\textit{@category}:\textbf{query}()
&
Query the current value of the counter in this \textit{@category}
without incrementing it.
(The ``\textit{@category}'' is usually either \textit{@atom}, \textit{@bond}, \textit{@angle}, \textit{@dihedral}, or \textit{@improper}.)
This is useful for counting the number of
atom types, bond types, angle types, etc... declared so far.)
\\
\hline
\begin{tabular}[t]{l}
\textit{@\textbf{\{}category:variable\textbf{\}}}\ or \\
Coordinate transformations introduced using the \textit{push()} command are applied to molecules instantiated later (using the \textit{new}) command, and remain in effect until they are removed using the \textit{pop()} command. (And transformations appearing in arrays accumulate as well, but do not need to be removed with \textit{pop()}.)
%The \textit{push()} and \textit{pop()} commands allow the user to control exactly how coordinate transformations accumulate. The \textit{pop()} command undoes the transformations introduced in the most recent \textit{push()} command.
In this example, the first transformation, ``rot()'', is applied to both ``monomer1'' and ``monomer2''. The last transformation, ``move()'', is applied after ``rot()'' and only acts on ``monomer2''.
\\
\hline
\end{tabular}
%\caption{Coordinate Transformation Commands}
%\label{tab:transformation_commands}
%\end{table}
\subsection{moltemplate.sh command line arguments:}
\label{sec:args_table}
%\begin{table}
\begin{tabular}[h]{l|p{10cm}}
\textbf{argument}&\textbf{meaning}
\\
\hline
\hline
-atomstyle \textit{style}
&
Inform moltemplate which atom\_style you are using.
(\textit{style} is "full" by default).
Other styles like "molecular" or "hybrid full dipole" are supported.
For custom atom styles, you can also specify the list of column
names manually. For example:
\textbf{-atomstyle "molid x y z atomid atomtype mux muy muz"}
Atom styles should be enclosed in quotes (").
\\
\hline
-raw coords.raw
&
Read all of the atomic coordinates from an external RAW file.
(RAW files are simple 3-column ASCII files contain X Y Z coordinates
for every atom, separated by spaces.)
\\
\hline
-xyz coords.xyz
&
Read all of the atomic coordinates from an external XYZ file
(XYZ files are 4-column ascii files in ATOMTYPE X Y Z format.
The first column, ATOMTYPE, is skipped.
The first line should contain the number of atoms.
The second line is skipped. See section \ref{sec:coords_intro}.)
\\
\hline
-pdb coords.pdb
&
Read all of the atomic coordinates from an external PDB file
(Periodic boundary conditions are also read, if present.
Atoms are sorted by the chainID, resID, insertCode, and atomID
fields on every line beginning with ``ATOM'' or ``HETATM''.
This order must match the order that the atoms appear in the data file.
See section \ref{sec:coords_intro}.)
\\
\hline
-a '\textit{variable}\textit{value}'
&
Assign \textit{variable} to \textit{value}.
(The \textit{variable} should begin with either a @ character
or a \$ character.
Single-quotes and a space separator are required.
See appendix \ref{sec:manual_assignment}.)
\\
\hline
-a bindings\_file'
&
The variables in column 1 of
\textit{bindings\_file}
(which is a text file)
will be assigned to
the values in column 2 of that file.
(This is useful when there are many variable assignments to make.
See appendix \ref{sec:manual_assignment}.)
% \$-variables should \textit{not} be preceded by \textbackslash\ in this case.)
\\
\hline
\begin{tabular}[t]{l}
-b '\textit{variable}\textit{value}'
\\
\hspace{0.35cm}\textit{or}\\
-b \textit{bindings\_file}
\\
\end{tabular}
&
Assign variables to values.
Unlike assignments made with ``-a'',
assignments made using ``-b''
are non-exclusive.
(They may overlap with other variables in the same category.
See appendix \ref{sec:manual_assignment}.)
\\
\hline
\begin{tabular}[t]{l}
-overlay-bonds
\\
-overlay-angles
\\
-overlay-dihedrals
\\
-overlay-impropers
\\
\end{tabular}
&
By default moltemplate overwrites
duplicate bonded interactions which
involve the same set of atoms.
These flags disable that behavior.
This can be useful when you want to superimpose
multiple angular or dihedral forces on the same set of atoms
(eg. to enable more complex force fields).
\\
\hline
-nocheck &
Do \textit{not} check for common LAMMPS/moltemplate syntax errors.
(This might be useful when using moltemplate
with simulation software other than LAMMPS,
\textit{or} to build systems which need new non-standard LAMMPS features.)
\\
\hline
-checkff &
This forces moltemplate.sh to check that there
are valid angle and dihedral interactions defined for every
3 or 4 consecutively bonded atoms in the system
(defined in "Data Angles By Type'' and ``Data Dihedrals By Type" sections).
\\
\hline
-vmd &
Invoke VMD after running moltemplate to view the system you have just created.
(VMD must be installed.
%This feature uses Axel Kohlmeyer's topotools plugin.
See sections \ref{sec:vmd_topotools}, \ref{sec:vmd_advanced} for details.)
\\
\hline
%-import-path LOCATION
%&
%When a user imports an .LT file, moltemplate first looks in the directory
%where it was run, and then in the ``force\_fields'' subdirectory in the
%moltemplate installation. Additional directories can be appended using
%this command. (Multiple directories must be separated by ':' characters)
%This allows moltemplate to look for .LT files
%in other directories when using ``import''.
%(Multiple directories must be separated by ':' characters.)
%\\
%\hline
\end{tabular}
\begin{tabular}[h]{l|p{10cm}}
\hline
\begin{tabular}[t]{l}
-dihedral-sym file.py
\\
-improper-sym file.py
\\
-bond-symmetry file.py
\\
-angle-symmetry file.py
\\
\end{tabular}
&
Normally moltemplate.sh reorders the atoms in each bond, angle, dihedral, and improper interaction before writing them to the DATA file in order to help avoid duplicate interactions between the same atoms if listed in different but equivalent orders. Sometimes this is undesirable. \textit{\textbf{To disable this behavior, set ``file.py'' to ``None''.}} You can also manually choose alternate symmetry rules for unusual force fields. (Such as class2 force fields, dihedral\_style spherical, etc... For an example of the file format for ``file.py'', see the ``nbody\_Impropers.py'' file.)
\\
\hline
\end{tabular}
%\pagebreak
\section{Introductory tutorial}
\label{sec:tutorial}
\subsection*{\textit{Summary}}
\textit{Moltemplate is based on a very simple text generator (wrapper) which
repetitively copies short text fragments into one (or more) files
and keeps track of various kinds of counters.}
LAMMPS is a powerful but complex program with many contributors.
Moltemplate is a front-end for LAMMPS.
Moltemplate users will have to tackle the same steep learning-curve
(and occasional bugs) that other LAMMPS users must face.
%Moltemplate is (intentionally) ignorant about LAMMPS
%and molecular dynamics in general.
%Gradually other features have been added to moltemplate.sh which make
%it somewhat more convenient for generating LAMMPS simulation files.
Moltemplate files (LT files) share the same file format and
syntax structure as LAMMPS DATA files and INPUT scripts.
%Moltemplate can understand some simple LAMMPS commands,
%and it will attempt to correct user mistakes.
Moltemplate will attempt to correct user mistakes,
however users must still learn
LAMMPS syntax and write LT files which obey it.
For users who are new to LAMMPS, the easiest way
to do this is to modify an existing example
(such as the water box example in this section).
(The official LAMMPS documentation
\url{http://lammps.sandia.gov/doc/Manual.html}
is an excellent reference to look up LAMMPS commands
you see in these examples that you are not familiar with.)
%In addition to the examples here, there are more complex examples
%distributed with the moltemplate source code.}
\subsection{Simulating a box of water using moltemplate and LAMMPS}
%Later on when we build the final LAMMPS input and data files,
%data from the different files (``Data Atoms'', ``Data Bonds'',
%``In Init'', ``In Settings'', etc...)
%must be pasted together in the correct order according to LAMMPS conventions.
%This is a simple task that can be performed by the ``moltemplate'' script
%(included with ttree),
%or manually by the user, depending on their familiarity with LAMMPS.
%LAMMPS has a complex and diverse syntax because
%it supports a wide variety of force-field types.
%The commands above are \textit{raw} LAMMPS commands,
%augmented by ttree variables
%(like ``@atom:O'' and ``\$atom:o''), which are explained below.
%and/or CHARMM27 parameter files.
%We hope ttree is flexible enough that it should remain useful in the future,
%even if the LAMMPS input syntax changes radically.
%\subsection{Before ttree}
%The ability to load and combine data from multiple different types of
%molecules together is missing from LAMMPS.
%\textit{Normally} LAMMPS users are required to manually assign unique
%id numbers to \textit{every} atom, bonded, 3-body, and 4-body interaction
%in the entire simulation.
%Each molecule is assigned a unique id number as well.
%For a system with 6000 water molecules, a user would be required to
%specify 18000 atom ids, 12000 bond ids, 6000 3-body angle ids
%and 6000 molecule ids.
%(This should not be done by hand.)
\subsection{Visualizing Trajectories}
\label{sec:vmd_trajectory}
After you have run a simulation in LAMMPS, there are several programs which
can visualize the system.
If you have saved your trajectory in LAMMPS ``dump'' format,
later you can view it in VMD \cite{VMD}.
For the purpose of viewing trajectories in LAMMPS,
I recommend using the following style of ``dump'' commands in the LAMMPS
input-script that you use when you run LAMMPS:
\begin{verbatim}
dump 1 all custom 1000 DUMP_FILE.lammpstrj id mol type x y z ix iy iz
\end{verbatim}
(The ``all'' and ``1000'', refer to the atom selection and save interval, which may differ depending on the kind of simulation you are running. See \url{http://lammps.sandia.gov/doc/dump.html} for details.)
Once you have a dump file, you can view it in VMD using:
In this example, only atoms whose type is 1, 2, or 3 are included.
\subsubsection*{Example 4}
\begin{verbatim}
ltemplify.py -name Mol -atomid "13141561*69" \
lammpsfile.in lammpsfile.data > mol.lt
\end{verbatim}
In this example, only atoms whose ids are
13, 14, 15, and 61 through 69 are included.
\subsubsection{ Fixes and Groups }
\label{sec:ltemplify_fix_group}
ltemplify.py has \textit{limited} support for ``fix'' and ``group'' commands,
including ``fix shake'', ``fix rigid'', and ``fix poems''.
Other fixes must be added manually to the file generated by ltemplify.py.
(Such as fix ``restrain'', ``bond/create'', ``bond/break'', ``ttm'', etc...)
ltemplify.py can understand simple (static) ``group'' commands, and will include them in the output file, if it can determine that they contain any relevant atoms. (Fixes depending on irrelevant groups are also deleted.)
\textit{Note: This feature has not been tested carefully. So please review all of the group and fix commands generated by ltemplify.py to make sure they refer to the correct atoms. And please report any bugs you find. (-Andrew 2014-10-29)}
\subsection{Known bugs and limitations (ltemplify.py):}
\label{sec:ltemplify_limitations}
%\subsubsection*{Wildcard characters ``*''}
%Support for wildcards is not consistent throughout an LT file.
%
%Wildcard characters like ``*'' currently mean different things
%in different places.
%In the \textit{write\_once(``Data Angles By Type'') \{...\}} section,
%for example, the ``*'' and ``?'' wildcard characters are interpreted
%as \textit{string wildcards}.
%This means that ``@atom:C?'' will match ``@atom:C1'', ``@atom:C2'', and
%``@atom:CA'', but \textit{not} ``@atom:CA2''.
%However ``@atom:CH*'' will match all of these examples.
%(See appendix \ref{sec:nbody_by_type}.)
%Moltemplate ignores ``*'' characters elsewhere in an LT file,
%and leaves it up to LAMMPS.
%
%
%This means that a ``*'' character appearing in a
%\textit{pair\_coeff},
%\textit{bond\_coeff},
%\textit{angle\_coeff},
%\textit{dihedral\_coeff},
%\textit{improper\_coeff},
%or
%\textit{group}
%command, for example,
%is interpreted (by LAMMPS) as a \textit{numeric wildcard}.
This means: find the closest ancestor of the \textit{\textbf{cpath}} object containing a category named ``\textit{\textbf{catname}}''. This ancestor determines the category's scope. Counter variables in this category are local to ancestors of that object. In this usage example, \textit{\textbf{lpath}} identifies the location of the variable's corresponding ``leaf'' object
relative to the category scope object (\textit{\textbf{cpath}}).
On the other hand, if the the category's scope (\textit{\textbf{cpath}})
was not explicitly stated by the user (which is typical),
then the \textit{\textbf{lpath}} identifies the location of the leaf object relative to
the object in which the variable was referenced
(the current-context ``.'').
\subsection{Variable shorthand equivalents}
\label{sec:variables_shorthand}
\subsubsection*{\$\textit{\textbf{catname}}:\textit{\textbf{lpath}} is equivalent to ``\$.../\textit{\textbf{catname}}:\textit{\textbf{lpath}}''}
%\label{sec:variables_shorthand_catname:lpath}
This means: find the closest direct ancestor of the current object containing a category whose name matches \textit{\textbf{catname}}. If not found, create a new category (at the global level). \textit{This is the syntax used most frequently in LT files.}
If the colon is omitted, as in \$\textit{\textbf{lpath}}/\textit{\textbf{catname}},
then it is equivalent to: \$\textit{\textbf{catname}}:\textit{\textbf{lpath}}.
Again, in these cases, \textit{\textbf{lpath}} is a path which is relative to the object
in which the variable was referenced.
If \$\textit{\textbf{lpath}} is omitted, then this is equivalent to \$\textit{\textbf{catname}}:. In other words, the the leaf node is the current node, ``.''. (This syntax is often used to count keep track of molecule ID numbers. You can use the counter variable ``\$mol'' to keep track of the current molecule id number, because it counts the molecular objects in which this variable was defined. In this case the name of the category is ``mol''. As in most examples, the category object, \textit{\textbf{cpath}}, is not specified. This means the category object is automatically global. A global category object means that every molecule object is given a unique ID number which is unique for the entire system, not just unique within some local molecule. As a counter-example, consider amino acid residue counters. Each amino acid in a protein can be assigned a residue ID number which identifies it within a single protein chain. However because their category was defined locally at the protein level, these residue ID numbers are not global, and are not uniquely defined if there are multiple protein chains present.)
Find the category name and object corresponding to ``\$\textit{\textbf{cpath}}/\textit{\textbf{catname}}:''
(see above)
If \$\textit{\textbf{cpath}}/ is blank, then search for an ancestor with a category whose name matches \textit{\textbf{catname}}, as described above.
To find the variable's corresponding ``leaf object'', start from the CURRENT object (not the category object). If \textit{\textbf{lpath}} is not empty, follow \textit{\textbf{lpath}} to a new position in the tree. Otherwise, start at the current object. (An empty \textit{\textbf{lpath}} corresponds to the current object.) From this position in the object tree search for a direct ancestor which happens to also be ``leaf object'' for some other variable which belongs to the desired category. If no such variable is found, then ttree creates a new variable whose leaf object is the object at the \textit{\textbf{lpath}} position, and put it in the desired category.
\subsubsection*{\$\textit{\textbf{lpath}}/.../\textit{\textbf{catname}} is equivalent to \$\textit{\textbf{catname}}:\textit{\textbf{lpath}}/...}
If \textit{\textbf{lpath}} is omitted, then start from the current node.
(In the molecular examples, ``\$.../mol'' is a variable whose category name is ``mol''. The ``leaf object'' for the variable is either the current object in which this variable was defined, OR a direct ancestor of this object which has been assigned to a variable belonging to the category named ``mol''. In this way large objects (large molecules) can be comprised of smaller objects, without corrupting the ``mol'' counter which keeps track of which molecule we belong to. In other words, ``\$.../mol'' unambiguously refers to the ID\# of the large molecule to which this sub-molecule belongs (regardless of however many layers up that may be).)
\textit{Variables in the output\_ttree/ttree\_assignments.txt file
use the this syntax.}
If the user explicitly specifies the path leading up to the cat node, and avoids using ``...'', then \textit{\textbf{lpath}} is interpreted relative to the category object, not the current object (however \textit{\textbf{cpath}} is interpreted relative to the current object). This happens to be the format used in the ``ttree\_assignments.txt'' file (although you can use it anywhere else in an ``.LT'' file). In ``ttree\_assignments.txt'' file, \textit{\textbf{cpath}} is defined relative to the global object. The variables in that file always begin with ``\$/'' or ``@/''. The slash at the beginning takes us to the global environment object (to which all the other objects belong). (Since the variables in the ``ttree\_assignments.txt'' always begin with ``\$/'' or ``@/'', this distinction is usually not important because the category object for most variables usually is the ``global'' root object.)