How to fix nvt for atoms within a region?

I want to thermalize a group of atoms defined within a small region in my simulation box. I want the atoms to remain within this small region while the thermalization happens. I checked the other related threads and found a thread that said “compute temp/region” might help. However, I this doesn’t keep the atoms within the region (allows atoms to enter/leave the region). How can I keep the atoms within the region while I thermalize?

First off, I think you are throwing together three different issues, that are best first considered individually. Those are:

  • time integration of particles
  • thermalization of particles
  • and confinement of particles

So the first question thus has to be: do you want to time integrate all particles or only the particles within your group/region?

Second question: do you want to apply thermalization to only the confined group/region or also thermalization to the remainder and do you want to do thermalization done in a way that there is an equilibrium (since there will be a flux of kinetic energy from the hotter region to the colder region then the colder region is mobile). In the other way around you have a non-equilibrium system since each subsystem would be equilibrated as if it was surrounded by atoms at 0K. You can either apply fix nvt to everything and then use a thermostat bias, or use fix nve for all and fix langevin for the hot group. Or you can apply fix nvt to only the hot area and fix nve or no time integration fix to the rest.

Third question: given that you don’t want your “hot” atoms to move away, you can just define a group and don’t need to play around with a thermostat bias. The bias would only be needed if you want to use fix nvt for all atoms. There are two basic approaches to confining atoms, you can apply (soft) walls or you can use fix spring/self. Each has advantages and limitations. Fix spring/self is probably easier.

Before I answer your questions I would like to clarify that all the particles are within the smaller region initially. Now answering your questions one by one:

  1. Yes, I want to time-integrate the particles such that they are under PBC within that region.
  2. Since no particles are initialized outside the region, I would like to maintain that and have thermalization within the region only (or in the whole simulation box keeping particles inside the region)
  3. This is not so much as confinement but more like distributing them uniformly.

I am attaching a snippet of my code hoping it will help you understand what I want to say.

region			simbox  block  0  ${lxx}  0  ${lyy}   0  1e-4 
create_box      	1 simbox

region          target   block   0.02	0.08    0.07	0.09  0   1e-4


create_atoms    1 random    ${Np}   322349  target

group                   system dynamic all region simbox
group                   diff  region  target

set			group all charge ${Qd}
#############################################################################

# Force field
pair_style		coul/debye ${kappa} ${cutf}
pair_coeff		* *

# Settings
neighbor		${ngh} bin
neigh_modify		every 1 delay 0  check yes
mass			* ${md}

compute			new3d all temp/region target
compute         1 all msd 
compute         2 all vacf


# equilibrate
velocity	    all create ${T} 5812775 temp new3d units box

# Outputs
thermo_style            custom step temp pe ke etotal epair press
thermo                  ${Nth}
thermo_modify           temp new3d

fix 1nvt    diff   nvt 	temp 	${itp}	${ftp}	${trx}
dump        dp0 all custom 1000 dump_nvt_0.1cf_thermalize.lammpstrj id type x y vx vy
run 	500000

unfix 1nvt
undump dp0
##########################################

fix             lan1 all langevin    ${itp} ${ftp}  ${damp}  8091823  

fix         eq2 all nve

Also I am getting Lost atoms error after the langevin fix.

Those questions were intended to be a guide for you to make informed choices. But answers 2 and 3 contradict each other. If you want to keep particles in a given region, how is this not a confinement?

Attaching an incomplete input is usually making things worse than being helpful. Murphy’s law dictates that the crucial bits of information are usually outside the part you are quoting.

Also, it would be helpful to know about the context of your simulation.

This makes no sense in the context of your original post. Originally, you said:

But now you want them to be distributed uniformly. This is contradicting each other.
Also, if you want a uniform distribution, why do you create the atoms at random positions and not on a regular grid (i.e. uniformly).

This is a completely different question.

I am sorry, but there is too much context missing, and your statements and questions are contradictory.
I don’t know how to give further advice to somebody that does not give a consistent description of the problem to solve.

I am sorry if I am not able to express my problem clearly. Let me try one more time.

I have 500 particles inside a small region with some initial temperature and velocity. I want them to diffuse throughout the simulation box. But before diffusing I want them to attain a thermal equilibrium inside the small region.
Re-reading what you have said, I think using fix temp/rescale (with no time integration) with particles initialized on a grid might help me achieve the same results. I think I have stated my problem correctly this time. Also, am I thinking right about using the fix temp/rescale?

No.

It still does not make much sense to me. Why care about creating an equilibrium with a confined system, when you plan to take the confinement away and thus have a non-equilibrium situation again.

I cannot tell and that is the reason why I choose to not participate in any further communications about this. You will need to find somebody else that is willing to communicate with your. It is probably best if you rethink some more and post the complete description of your problem and complete input in a new post. That won’t change my decision to not participate, but may increase your chances to get a response compared adding to this discussion thread.

I think you (@Aman ) got some useful information in this exchange with Axel (regardless of any agreement or understanding) :fairy: :fairy:

You learnt ways to confine your atoms in a region when he said:

For the first option, check the region and the fix wall/region commands (fix wall/region command — LAMMPS documentation and region command — LAMMPS documentation). You, who knows your system better than any of us, can do some reading and evaluate whether or not this is useful for you.

For doing the dynamics inside the region and eventually reaching the temperature you want with the help of some thermostat, you can simply check the command lines that allows you to assign equations of motion cherishing thermostats to your atoms (e.g., fix nvt) and beware of what you put in the “group-ID”. Some other ideas on how you can do the dynamics have also been pointed out to you.

And as an extra you can now think if some issues that were pointed out for you (e.g., the possibility of having a non-equilibrium system) will indeed be problematic for the sake of what you are trying to do.

2 Likes

Thank you for being so helpful. I will think more deeply about this.

1 Like