Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amirhs1 opened this issue Apr 6, 2022 · 6 comments
Open

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

amirhs1 opened this issue Apr 6, 2022 · 6 comments
Labels

Comments

@amirhs1
Copy link

amirhs1 commented Apr 6, 2022

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

@amirhs1 amirhs1 changed the title How to use How to use LAMMPS variable command in forcefield.lt Apr 6, 2022
@hothello
Copy link
Contributor

hothello commented Apr 6, 2022

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
Copy link
Author

amirhs1 commented Apr 6, 2022

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
Copy link
Owner

jewettaij commented Apr 7, 2022

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
Copy link
Owner

jewettaij commented Apr 7, 2022

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...)

@jewettaij jewettaij changed the title How to use LAMMPS variable command in forcefield.lt How to use LAMMPS' variable command in an .LT file Apr 7, 2022
@jewettaij jewettaij changed the title How to use LAMMPS' variable command in an .LT file How to use LAMMPS' "variable" command in an .LT file Apr 7, 2022
@hothello
Copy link
Contributor

hothello commented Apr 7, 2022

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.

@amirhs1 amirhs1 closed this as completed Apr 7, 2022
@jewettaij
Copy link
Owner

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

@jewettaij jewettaij reopened this Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants