SIMPLE configuration building tool

Hi all,

Is there a tool (maybe a python tool) to build a simple input file to be read by read_data that obeys the canonical LAMMPS data file formatting? There didn’t appear to be anything like this in the pizza.py scripts. I’m looking at, e.g., examples/micelle/data.micelle and using that as my starting point, but it complains about my formatting and this is hard to debug. It would be nice if there was a tool available to do this with the canonical LAMMPS formatting. Not looking at putting together complicated bio-molecules… just a few particles where I want them.

I’m trying something drop-dead simple, and it doesn’t like SOMETHING about my formatting, and I don’t have time to get out the debugger and step through the code to figure out what, precisely it doesn’t like. It’s not clear to me whether I’m always required to put the moleculeID and charge if the atom style doesn’t require it. But I tried various versions with/without moleculeID and charge information.

Thanks,
Craig

------------------------ here’s the data file I’m trying to read with read_data ------------------

LAMMPS Description

2 atoms

1 atom types

0.0 10.0 xlo xhi
0.0 10.0 ylo yhi
-0.5 0.5 zlo zhi

Masses
1 1.0

Atoms
1 0 1 0.0 0.0 0.0
2 0 1 0.0 0.0 0.0


Hi @Craig_Maloney2,

Why not use LAMMPS itself? It has some building capabilities which allow for already complex structures. Is there a specific need for you to want to load/read the data files with some Python script?

This depends on the atom_style. Short answer: no, Long answer: the format of each atom style is described in the read_data command’s manual page.

Please have a look at: Pre/Post Processing Tools for use with LAMMPS

What are the error messages you get?

-------------------- [maloney@Craigs-MacBook-Pro:~/projects/2023-05-14-lammps-python-test]$ cat initialData.dat
LAMMPS Description

2 atoms

1 atom types

0.0 10.0 xlo xhi
0.0 10.0 ylo yhi
-0.5 0.5 zlo zhi

Masses
1 1.0

Atoms
1 0 1 0.0 0.0 0.0
2 0 1 0.0 0.0 0.0

(base) [maloney@Craigs-MacBook-Pro:~/projects/2023-05-14-lammps-python-test]$ cat commands-trivial.lmp
read_data initialData.dat


ERROR: Incorrect atom format in data file: 2 0 1 0.0 0.0 0.0 (…/atom.cpp:1039)

(base) [maloney@Craigs-MacBook-Pro:~/projects/2023-05-14-lammps-python-test]$ ~/download/lammps-23Jun2022/src/lmp_serial < commands-trivial.lmp
LAMMPS (23 Jun 2022 - Update 4)
Reading data file …
orthogonal box = (0 0 -0.5) to (10 10 0.5)
1 by 1 by 1 MPI processor grid
reading atoms …
ERROR: Incorrect atom format in data file: 2 0 1 0.0 0.0 0.0 (…/atom.cpp:1039)
Last command: read_data initialData.dat


Looks like it is parsing the first of two atoms OK and failing on the second one? MacOS crlf error???

Blockquote Why not use LAMMPS itself? It has some building capabilities which allow for already complex structures. Is there a specific need for you to want to load/read the data files with some Python script?

I’m using the python interface and issuing a bunch of “create_atom single” commands, but that seems a bit kludgey. I should be able to figure out how to format a simple input file. But I guess it’s fine issuing a bunch of “create_atom single” commands, and I’ll live with it.

No, you are not following the documented format. Note the remarks about required empty/ignored lines after section headers.

No, you are not following the documented format. Note the remarks about required empty/ignored lines after section headers.

Could you please give an example of a properly formatted version? This is the most trivial example I could come up with having more than 1 atom.
Thanks.

I can give you an example on how it looks like for the “full” atom style. It is not a stye as simplistic as the one you are trying to set up but it serves as an example for this style at least.

pos.dat (409.6 KB)

It’s not clear to me whether I’m always required to put the moleculeID and charge if the atom style doesn’t require it.

The required “attributes” that you need to specify in the data file depends on the style (there are different styles). In other words, each style has a different set of “attributes”, so whether you need to specify one thing or another depends on the style you intend to use. As Germain said, this information you can find in the “read_data command” page of the manual. I dont think there is a “canonical LAMMPS data formatting”, if I understood correctly what you meant by that.

Is there a tool (maybe a python tool) to build a simple input file to be read by read_data that obeys the canonical LAMMPS data file formatting?

Once you master the general formatting rules (spacings, “attributes needed” for the given style you are using, etc), you can always have your own python code to build an inital microstate cherishing the desired relative positionings + the corresponding connectivity. Then afterwards, it is just ctrl C, ctrl V.

Or, if you already have the initial microstate in another format, there are many different softwares that can read a file in format “whatever” and allow you to export it to a LAMMPS data format of different styles.

Why not do it all in LAMMPS?

region mybox block 0 10 0 10 0 10
create_box 2 mybox

create_atoms 1 single 0 0 1
create_atoms 1 single 2 0 6

write_data my.data

(+/- some other setup commands whose absence will be easier to debug)

1 Like

haha :"D

Yeah… I end up invoking the lammps python interface and calling create_atoms single a bunch of times ( I obviously want more than 2) from the python interface to put the atoms where I want and then calling write_data through the python interface. But it just seems silly/inconvenient/frustrating to me that the required input data file formatting is so finicky that I can’t just figure out what’s wrong with the formatting in my input data file.

Your response doesn’t have enough information for me to determine what is wrong with the format of my data file. Could you please indicate which required empty lines I failed to leave empty? Thanks!

:laughing:

This is just a matter of taste but I like the LAMMPS data file, because it’s human readable (ever may it be so). You don’t have to splice together little filescraps from all across your project, or reprocess it into binary gobbledygook just to change bond topology (looking at you, GROMACS).

Sure, it can be finicky with whitespace and empty lines and so on, but I think it strikes a good balance between editable and expressive. I’ve screwed around with my data files via awk a lot and never really had any adverse side effects.

I guess you could just diff the LAMMPS-generated data file with your own version and see if there’s a difference?

Axel already pointed out the issue with your format. :wink:

Compare the format with the output of the script from @srtee.

1 Like