jewettaij / moltemplate

A general cross-platform tool for preparing simulations of molecules and complex molecular assemblies
http://www.moltemplate.org
MIT License
254 stars 99 forks source link

How to use LAMMPS' "variable" command in an .LT file #71

Open amirhs1 opened 2 years ago

amirhs1 commented 2 years ago

Hi,

I am new to moltemplate, so I am sorry if I asking a (trivial) question here. I wanna create forcefield.lt. Can I use LAMMPS variable command in my script? I would like then use this forcefield.lt as a template and produce a collection of LAMMPS input files by bash scripts.

For instance I want to have the following command in my LAMMPS script

variable cutoff11 equal ${sig1}*1.12246205

where sig1 is then given to LAMMPS as an argument with the command-line option lmp_serial -var sig1 VALUE.

Please see the part of the input file that I want to use variable command in.

example.txt

Thanks

Amir

hothello commented 2 years ago

Sure, Moltemplate is agnostic to the commands that you pass to LAMMPS. You only need to protect the variables that are not ment to be processed by Moltemplate. Therefore, the line that goes in your forcefield.lt script is: variable cutoff11 equal \$\{sig1\}*1.12246205

amirhs1 commented 2 years ago

Thanks for your response. Since I am new to Moltemplate, can I continue asking questions in this issue as I encounter difficulties in designing my system? Or it is better to open new issues for new (and possibly trivial) questions?

jewettaij commented 2 years ago

Thanks Otello!

Actually Otello recently supplied an file which demonstrates how to do this. See below:

https://github.com/jewettaij/moltemplate/blob/master/tests/test_molc_files/system.lt

Yes, the \ is necessary before the $ and {} characters, because those characters have special meanings in moltemplate.

(If you put "${sign1}" instead of "\$\{sign1\}" in your LT file, I'm not sure what will happen. Moltemplate will probably assume you are referring to an $atom:, $bond:, $angle:,... integer counter (or some type of new user-defined counter category named "sign1"), and then print out some incomprehensible error message. (Is that what happened?))

If you have additional questions, I suggest starting new issues in the github issue tracker (instead of burying them here in this thread). It may be a few days before I reply to them, but I do notice it when new issues appear on the moltemplate github page. (I'm vain enough to check that page regularly.)

This question was fine. If your future questions are really specific to what you are working on and unlikely to be something that anyone else would care about, then I suggest emailing them to me instead (jewett.aij -at- gmail.com).

jewettaij commented 2 years ago

Oh, and if you are creating a force-field and want other people to use it, great! Please send it to us, along with an example. (We like examples...)

hothello commented 2 years ago

Another good place where to discuss force field development is the LAMMPS section of https://matsci.org/, which will soon replace the historic mailing list.

jewettaij commented 2 years ago

I think I'll leave this open for a little while in case anyone else has the same question. (Reopening this issue...)