Simulating bulk fluid between two walls

Hi All,
I have a mixture system of water and an alcohol which I want to put between two walls to simulate a channel. The problem is I have the LAMMPS data file containing the mixture system but I need to create a wall of fcc atoms on top and bottom boundary of the box and can’t figure out a way to do this in LAMMPS. I appreciate any help on how to do this. Thanks

Converting a liquid bulk system into a non-periodic system can be tricky business.

Technically, the procedure should be very simple:

However, there are complications from having to “split” a bulk system. If you have spend significant simulation time, you will probably have lots of atoms with non-zero image flags. They can create problems with expanding the box, because that can change their relative positions, if not all atoms have the same image flags. A simple approach to address with would be to use the reset_atoms command — LAMMPS documentation with the image option to fold back molecules as much as possible into the original cell and then use an atom style variable storing the image flag in the direction that you want to make non-periodic (most people choose z) and then use this with the delete_atoms command — LAMMPS documentation with the “mol yes” option to delete all molecules that are still “sticking out”.

As second complication is that you creating a significant “shock” for the atoms that used to be in the bulk and are now suddenly at an interface. That can create phonons that can mess up your dynamics for a significant amount of time. So it is necessary to do more equilibration after that, and best with a dissipative thermostat, like fix langevin using a time constant at the shorter end of the typical scale to get rid of those effects.

1 Like

Here is an example for implementing such a procedure with a pre-equilibrated SPC/E water box where some carbon-like atoms are inserted to form two walls.

units		real	
atom_style	full

read_data	data.spce extra/atom/types 1

pair_style	lj/cut/coul/cut 12.0

mass 3 12.011

pair_coeff	1 1 0.15535 3.166
pair_coeff	* 2 0.0000 0.0000	
pair_coeff      3 3 0.05 3.20723   # carbon-like atom as placeholder
bond_style	harmonic
angle_style	harmonic

bond_coeff	1 1000.00 1.000
angle_coeff	1 100.0 109.47

special_bonds   lj/coul 0.0 0.0 1.0

neighbor        2.0 bin

reset_atoms image all

compute imgz all property/atom iz
fix imgz all ave/atom 1 1 1 c_imgz
variable imgz atom f_imgz
run 0 post no

delete_atoms variable imgz mol yes
reset_atoms id
change_box all z final -15 50 boundary p p f

unfix imgz
uncompute imgz
variable imgz delete

lattice fcc 4.0 origin 0.1 0.1 0.1

region lwall block EDGE EDGE EDGE EDGE -5 -3 units box
region rwall block EDGE EDGE EDGE EDGE  39 42 units box

create_atoms 3 region lwall
create_atoms 3 region rwall

group water type 1 2
group wall type 3

fix		1 water shake 0.0001 20 0 b 1 a 1
fix		2 water nve
fix             3 wall setforce 0.0 0.0 0.0

thermo 10

minimize 0.001 0.001 1000 10000

reset_timestep 0
timestep	1.0
thermo 50

dump 1 all atom 50 walls.lammpstrj

run 200 post no

fix             4 water langevin 300.0 300.0 5.0 645734
run 700
write_data data.walls

2 Likes

What about something like

...
reset_atoms image all
fix old_z all store/state zu
(run 0?)
variable old_z atom f_old_z
change_box ...
set group all z v_old_z

to avoid deleting molecules?

2 Likes

Correction: I misread and misunderstood what is the suggestion.

The suggested change might work, but then the walls will have to be farther away from the system to accommodate the atoms that “stick out”. With water this is only a small distance, but with larger molecules, that may cause a bigger problem and then too much vacuum is added. How to get the desired density in between the walls when following this route of system preparation is a challenge anyway. I generally prefer not to convert an equilibrated bulk system, but equilibrate a non-periodic system in the first place and use fix wall/harmonic to confine atoms.

1 Like

Another option is to perform a small miracle and part the water (through fix addforce and atom-style variable) :slight_smile:. After the parting you just need do displace all atoms, so that the vacuum is at the edge of the simulation box. Reset image flags, change boundary conditions to non-periodic and you have your system.

Input file based on the one by @akohlmey

units		real	
atom_style	full

read_data	data.spce extra/atom/types 1

pair_style	lj/cut/coul/cut 12.0

mass 3 12.011

pair_coeff	1 1 0.15535 3.166
pair_coeff	* 2 0.0000 0.0000	
pair_coeff      3 3 0.05 3.20723   # carbon-like atom as placeholder
bond_style	harmonic
angle_style	harmonic

bond_coeff	1 1000.00 1.000
angle_coeff	1 100.0 109.47

special_bonds   lj/coul 0.0 0.0 1.0

neighbor        2.0 bin

group water type 1 2
group wall type 3

fix		1 water shake 0.0001 20 0 b 1 a 1
fix		2 water nve

variable    d equal 10

variable    wall   atom (((z-20)>0)-((z-20)<0))*(abs(z-20)<ramp(0,$d/2))*mass*abs(z-20)*100

fix     addforce all addforce 0 0 v_wall

thermo 10

dump 1 all atom 50 walls.lammpstrj

timestep	0.1
thermo 50 

fix             4 water langevin 300.0 300.0 5.0 645734
fix             5 all deform 100 z delta -$(v_d/2) $(v_d/2)
run 2000
unfix           5
variable    wall   atom (((z-20)>0)-((z-20)<0))*(abs(z-20)<$d/2)*mass*abs(z-20)/5 #make the wall softer
run 2000
write_data data.walls

test

3 Likes

Thank you very much for your response, Axel. I don’t intend to convert an already equilibrated water-alcohol system because I might mess up the dynamics. I just have the initial configuration of the system (pre-equilibration) in a data file and just want to put it between two walls and equilibrate the system.

This miracle is cool :grinning:! But I intend to start with a system that’s not already equilibrated. I think that’s safer for me. Thanks a lot!

1 Like

Then you can just make the box larger in the data file directly with a text editor and use the same procedure as shown with read data to add an atom type and then use create_atoms to create the atoms. Please make certain that the box dimensions are commensurate with the lattice spacing of the material you want to use for the walls.

1 Like

Thank you so much! I will keep this in mind.

Hi Axel,

I followed the example you posted, it works great. Some of my alcohol molecules are getting deleted. The water molecules are fine. How can I solve this? I need to maintain a ratio of alcohol and water in the system. Thanks.

There are multiple suggestions for how to deal with that in this discussion thread.