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

Help for reading coordinates from pdb files. #81

Open
ms123456-TX opened this issue Aug 5, 2022 · 1 comment
Open

Help for reading coordinates from pdb files. #81

ms123456-TX opened this issue Aug 5, 2022 · 1 comment

Comments

@ms123456-TX
Copy link

Dear Professor,

I want to use moltemplate to add information such as key corners from the pdb file created by packmol, but when I run:
moltemplate.sh -pdb start.pdb -atomstyle "full" system
lt it reports an error stating:
Error: Number of atoms in coordinate file provided by user (23238) does not match the number of atoms generated in ttree file (9798).

My system is graphene electrode with ionic liquid system,When I was troubleshooting the error, I found that when I read just the graphene or water or Li ions individually, I could read their pdb file coordinates, but when I read them together I had a problem with not being able to match the pdb coordinates.

This problem has been bothering me for a long time, and my lt files are written strictly according to the syntax.Here, I sincerely ask for your help!

Thanks a lot!

Here, I attach my lt files.
case.zip

@jewettaij
Copy link
Owner

jewettaij commented Aug 12, 2022

I want to use moltemplate to add information such as key corners from the pdb file created by packmol, but when I run: moltemplate.sh -pdb start.pdb -atomstyle "full" system lt it reports an error stating: Error: Number of atoms in coordinate file provided by user (23238) does not match the number of atoms generated in ttree file (9798).

My system is graphene electrode with ionic liquid system,When I was troubleshooting the error, I found that when I read just the graphene or water or Li ions individually, I could read their pdb file coordinates, but when I read them together I had a problem with not being able to match the pdb coordinates.

Please forgive me. This has been a particularly bad month, and I've been forced to ignore moltemplate questions for a couple weeks. (Unfortunately moltemplate is not relevant to my current job. I reply moltemplate questions intermittently when I have time.)

Without your PDB file(s), I could not tell what went wrong. However I realize that PDB files can be quite large. Don't post them here. But if the size of each PDB file is less than 25mb, then try emailing each file to jewett.aij -AT- gmail.com (One file per email.)

In the absence of the PDB files, I will do my best to try and figure out what might have gone wrong. Here are some guesses what might have caused this error:

Perhaps you did not include the entire system in your "system.lt" file?

When you run moltemplate.sh without the "-pdb start.pdb" argument, it generated a LAMMPS DATA file (named "system.data") containing 9798 atoms. (These are the atoms that are created when moltemplate carries out all of the "new" commands in your "system.lt" file.)

However you have more atoms in your PDB file (23238). This suggests that you forgot to include some molecules in your "system.lt" file, or that at least one of your molecule files (eg "gra.lt", "Li.lt", "pyr.lt", "TF2N.lt", or "water.lt") does not contain enough atoms.

I think this is the most likely explanation. In the interest of being thorough, I made some additional suggestions below. But don't think my suggestions below are probably relevant to your error message, and I hope I don't scare you away by suggesting something complicated that is not relevant to your issue.

Other common problems when using the -pdb and -xyz arguments

When you use moltemplate.sh with the "-pdb FILE.pdb" argument, then all of the atoms in your system must be present in that PDB file (FILE.PDB). (Furthermore the order of atoms in the PDB file must match the order of atoms in the "system.data" file, created by moltemplate. However this does not seem to be the error you are running into yet.)

Combining multiple PDB or XYZ files into one file before running moltemplate.sh

From what you wrote, it sounds like you have different portions of your system built in different ways and stored in different files.

If you are using PDB or XYZ files then all of the coordinate data for the entire system must be in one file. If you have multiple PDB files (eg "graphene.pdb" and "liquidmixture.pdb"), then it should be possible to concatenate them together into one larger file:

cat graphene.pdb liquidmixture.pdb > graphene_liquidmixture.pdb

...and use this new file with moltemplate.sh:

moltemplate -pdb graphene_liquidmixture.pdb system.lt

(For any other readers, if you had two XYZ files, you can combine the two by concatenating them. However you must to remove the 2-line header from the second file before concatenating and update the number on the second line to count the total number of atoms.)

Combining PDB/XYZ files with move() commands

However, life is more complicated if you want to use moltemplate to build part of the system using moltemplate's explicit ".move()" commands, and part of the system using a PDB or XYZ file (created by PACKMOL, for example). Is that what you are doing?

If so, then I suggest that you use moltemplate to build the portion of the system that you have in your PDB file or XYZ file. Suppose you have a PDB file (eg "liquidmixture.pdb") containing everything but the graphene. And suppose you want to build the graphene using moltemplate's move commands. (Example here.) In that case, I would:

  1. Run moltemplate.sh to convert the lipidmixture.pdb file into a LAMMPS DATA file this way:
moltemplate -pdb lipidmixture.pdb  system_lipid_mixture_only.lt

(The "system_lipid_mixture_only.lt" is a version of the "system.lt" file which omits the lines which instantiate the graphene, but is otherwise identical to "system.lt". In your case, I would comment out the line: "GRA = new gra[4800]") This will create three files:

  • system_lipid_mixture_only.in.init
  • system_lipid_mixture_only.in.settings
  • system_lipid_mixture_only.data
  1. Run "ltemplify.py" to convert these files into a moltemplate file (.lt file).
ltemplify.py -name LiquidMixture \
  system_lipid_mixture_only.in.init \
  system_lipid_mixture_only.in.settings \
  system_lipid_mixture_only.data \
  > liquidmixture.lt

(Note: The "ltemplify.py" program is explained in detail here and here.)

  1. Then I would create a "system.lt" file containing references to the two portions of the system. It might look something like this:
import "graphene.lt"
import "liquidmixture.lt"

liquid_mixture = new LiquidMixture
liquid_mixture.move(0,0,7.38)   # Optional: move all the atoms in "liquid_mixture" upwards in the Z direction by 7.38 Angstroms

# You can control the position of the graphene atoms using moltemplate's ".move()" commands.
# For example to create a hexagonal sheet containing 14 x 13 unit cells, use:
graphene_sheet = new Graphene [14].move(1.2297560733739, 2.13, 0)
                              [13].move(2.4595121467478,   0,  0)
# (This is a hexagonal crystal, so choose your "Data Boundary" box size carefully.)

graphene_sheet[*][*].move(0,0,-24.3)    # Optional: move the sheet downward in the Z direction by 24.3 Angstroms.

write_once("Data Boundary") {
 -15.98682895386 15.98682895386  xlo xhi   # = (1/2)*13*2.4595121
 -14.91          14.91           ylo yhi   # = (1/2)*14*2.13
 -31.0           31.00           zlo zhi
}

This example refers to the "graphene.lt" file that defines the "Graphene" unit cell. It can be found here.

The "liquidmixture.lt" file was created earlier by "ltemplify.py".

If you are still confused, please send me your PDB files (by email).
-Andrew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants