Creating an atom near another atom, without specifying coordinates

I’m looking to create_atoms near a specific atom at the end of a coarse grained polymer. The option single works if you specify x y z (e.g. “create_atoms 3 single 0 0 5”, from documentation on bond_style special command — LAMMPS documentation), but I’m wondering if there is a way to add an atom near another, to extend a chain, or join two chains of atoms (e.g. to link two DNA or peptide chains with a flexible, coarse grained linker)? Workarounds are acceptable too, so long as they make this task simpler than manually putting every atom in place for a large simulation.

These kinds of tasks are usually better done outside of LAMMPS with external tools or custom scripts/programs. While LAMMPS has a few commands for system/topology building, they are intended for small adjustments, not as a primary system building facilities. For growing polymer chains, you may have some luck with fix bond/react. I don’t have much experience with it, but it has some fancy mechanisms to add/change bonding.

If you want to use scripting and LAMMPS, you may want to look into using the LAMMPS python module. That way you have a real programming language to work with. But be warned, assessing internal topology data in LAMMPS is still a bit clumsy. This is in part because all interfaces and facilities in LAMMPS must be designed to be run in parallel with very many processors. A restriction that does not apply to common tools for topology/geometry building and manipulations.

1 Like

Here is a video that uses the ‘fix bond/react’ capability that Axel mentioned and demonstrates the use case you are requesting.


Wow. That’s absolutely fantastic. Do you have code that goes with it? I’ve learned to just create_atoms using regions and that works, but for DNA, it has a phosphate backbone (which are two polymers that straddle and twist along the central base pair polymer)… and if I can get the molecules to just extend outwards, that seems a lot cleaner than just putting a bunch of DNA residues in straight lines. It works for a tiny simulation, but if I want to do more, I have to do a lot of work that isn’t quickly replicated. If you can post the code for that or something also helpful that is similar, that would be fantastic.

Yes, this feature is already available in LAMMPS and this example also comes bundled with software. It can be found here: examples/PACKAGES/reaction.
Please let me know with any questions.

1 Like