How to have a fixed box length in the x and y direction when running npt simulation

Hi everyone,
I am trying to build a system of graphite and polymer (The polymer will be built with the graphite in the box using an in-house code). I want my box size to be exactly the length of my graphite in the x and y direction so that the polymer will only have contact to the surface normal to the graphite. When I run NPT (used keyword aniso for the barostat parameter) simulation in LAMMPS, I see the box length increasing in both the x and y directions, which I do not want. The box needs to be periodic in all directions. How can I prevent the system from expanding in the x and y directions while running NPT to relax it? I have attached a picture and the direction of the big arrow is the z direction.
Structure_Graphite_PEO.tif (160.9 KB)

How to do this is explained in the fix npt documentation.

Thank you for your reply. Maybe I should have said in my initial message that I applied pressure in the z direction alone but the length kept increasing in the z direction. I have gone through the fix npt documentation but couldn’t find anything that could help solve this problem. Can you be more specific about this? Thanks.

In the fix npt page of the manual you can find the following part:

“The target pressures for each of the 6 components of the stress tensor can be specified independently via the x, y, z, xy, xz, yz keywords, which correspond to the 6 simulation box dimensions. For each component, the external pressure or tensor component at each timestep is a ramped value during the run from Pstart to Pstop. If a target pressure is specified for a component, then the corresponding box dimension will change during a simulation. For example, if the y keyword is used, the y-box length will change. If the xy keyword is used, the xy tilt factor will change. A box dimension will not change if that component is not specified, although you have the option to change that dimension via the fix deform command.”

Hi Cecilia,

Yes, I know about this and that was why I applied pressure just to the z components. When I did this, I had a constant x and y length but my box kept on increasing in the z direction which is my major concern.

Ah, sorry, I had not properly read what you had said in your second message. I suppose the length is increasing in the z direction in order to suit the target pressure you input. Is it increasing indefinitely or does it equilibrate? Can you maybe share some relevant parts of the input script and/or give us more information?

EDIT: maybe it is worth checking the parameters of your potential and also if the initial configuration doesnt have atoms super close or something on these lines.

This is the exact opposite of what you wrote in your original message. You cannot expect meaningful advice if you give wrong information.

What is it now for real? What is your input? What is the output/log you get? What are the pressure components printed? What is the energy?

Also, there seems to be a misconception here: if you use fix npt with the z box component only, the fix will try to keep the pressure close to your target, not the box length in that direction.

Yes, the box kept increasing indefinitely in the z-direction. Here is my input script and the log script.

log.lammps (896.6 KB)
in.Harmonic (1.8 KB)

I don’t see anything out of the ordinary or massive mistake. The system will just go into the direction the forces dictate and apparently, your system “wants” to expand. That can be due to unsuitable force field parameters and settings or a bad geometry (there is quite a spike in temperature at the beginning of the MD hinting at a less than ideal geometry that undergoes some transformation. That you should be able to see from visualization.

There is no specific advice that can be given at this point without investing a significant amount of time to actually figure out and reproduce the specific scientific problem you want to solve.

The only thing that stands out is that you are using an over 5 year old LAMMPS version. Not recommended.