Fixed pressure-volume simulation


I know that barostat usually keep the pressure fixed by altering the volume, but is there any way to couple the pressure to the number of atoms and keep the volume fixed too?
I am trying to simulate an open system (where matter can leave the system) at fixed pressure

You need to provide some more details about your system and what kind of process you want to model.

I am not aware of any option in LAMMPS that allows to set up a semi-grand ensemble (in fact, I am not aware of any MD package that does).

Usually a canonical ensemble ensemble (NVT) will also preserve pressure when in equilibrium.

Thanks, Axel. I am simulating the melting process at constant pressure using an isenthalpic-isobaric ensemble, but the temperature of the system drops as the solid melts. I think that is due to the expansion of the box, which occurs to keep the pressure constant. I would want to keep the temperature of the system constant while melting; thus, I was thinking about fixing the pressure via the removal of the molten atoms rather than expanding the box.

That is pure speculation. You need to discuss this with somebody that has a sufficient understanding of statistical mechanics and thermodynamics. I think you need to learn some more about the thermodynamics of phase transitions and how this is reflected in molecular dynamics simulations.
It is quite typical that melting consumes large amounts of kinetic energy once it has started.

That seems to me like a bad idea. In general, I very much dislike any approach like you are describing where you make speculative changes in order to avoid an unexpected behavior without first completely understanding what is the cause.

It is not just speculation! We heat the system through an imposed thermostat to the box’s boundaries. Thus, although the melting consumes KE, we do not expect this KE consumption to lead to sharp decreases in the average temperature of the system as we are heating it…

And talking about thermodynamics, we expect that phase change occurs at a constant temperature if you might recall from any thermodynamic book.

It is speculation. You are applying macroscopic thinking to a system that isn’t and you are also ignoring the characteristics of Nose-Hoover thermostats.

At the microscopic level, Temperature as such is not very well defined to begin with (you are assuming equipartitioning) and you have system size dependent fluctuations even for a system in equilibrium, so “constant” only applies on a sufficiently long timescale and when the system is in equilibrium and equipartitioning can be applied. However that is obviously not the case in your system.

My system is 100 nm big in the x direction and 10 nm big in other directions, and I do microseconds simulations. This is what made me think that it may represent a macroscopic model…

This is definitely not macroscopic. Macroscopic would be so large that you would not need a thermostat to adjust the temperature because the embedding system is so large that transferred kinetic energy is infinitesimally small.

But let us not get hung up on just one issue. There are other possible reasons for unexpected behavior like bad simulation settings, bad force field etc.

My main message remains the same: it is not a good idea to modify your system without fully understanding why those modifications are needed and with a good physical justification for the specific change. Both is missing here.