Skip to content
Snippets Groups Projects
Commit 4d4c03a1 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

restore gaussian flow example that was lost. tweak input to make it usable for comparing

parent 8a1db83b
No related branches found
No related tags found
No related merge requests found
The input script in.GD is an example simulation using Gaussian dynamics (GD).
The simulation is of a simple 2d Lennard-Jones fluid flowing through a pipe.
For details see online LAMMPS documentation and
Strong and Eaves, J. Phys. Chem. Lett. 7(10) 2016, p. 1907.
Note that the run times and box size are chosen to allow a fast example run.
They are not adequate for a real simulation.
The script has the following parts:
1) initialize variables
These can be modified to customize the simulation. Note that if the
pipe dimensions L or d are changed, the geometry should be checked
by visualizing the coordinates in all.init.lammpstrj.
2) create box
3) set up potential
4) create atoms
5) set up profile-unbiased thermostat (PUT)
see Evans and Morriss, Phys. Rev. Lett. 56(20) 1986, p. 2172
By default, this uses boxes which contain on average 8 molecules.
6) equilibrate without GD
7) initialize the center-of-mass velocity and run to achieve steady-state
The system is initialized with a uniform velocity profile, which
relaxes over the course of the simulation.
8) collect data
The data is output in several files:
GD.out contains the force that GD applies, and the flux in the x- and
y- directions. The output Jx should be equal to the value of
J set in section 1, which is 0.1 by default.
x_profiles contains the velocity, density, and pressure profiles in
the x-direction. The pressure profile is given by
(-1/2V)*(c_spa[1] + c_spa[2]), where V is the volume of a
slice. The pressure profile is computed with IK1, see
Todd, Evans, and Davis, Phys. Rev. E 52(2) 1995, p. 1627.
Note that to compare with the pump method, or to
compute a pressure drop, you must correct this pressure
profile as described in Strong 2016 above.
Vy_profile is the velocity profile inside the pipe along the
y-direction, u_x(y).
#LAMMPS input script
#in.GD
#see README for details
###############################################################################
#initialize variables
clear
#frequency for outputting info (timesteps)
variable dump_rate equal 50
variable thermo_rate equal 10
#equilibration time (timesteps)
variable equil equal 1000
#stabilization time (timesteps to reach steady-state)
variable stabil equal 1000
#data collection time (timesteps)
variable run equal 2000
#length of pipe
variable L equal 30
#width of pipe
variable d equal 20
#flux (mass/sigma*tau)
variable J equal 0.1
#simulation box dimensions
variable Lx equal 100
variable Ly equal 40
#bulk fluid density
variable dens equal 0.8
#lattice spacing for wall atoms
variable aWall equal 1.0 #1.7472
#timestep
variable ts equal 0.001
#temperature
variable T equal 2.0
#thermostat damping constant
variable tdamp equal ${ts}*100
units lj
dimension 2
atom_style atomic
###############################################################################
#create box
#create lattice with the spacing aWall
variable rhoWall equal ${aWall}^(-2)
lattice sq ${rhoWall}
#modify input dimensions to be multiples of aWall
variable L1 equal round($L/${aWall})*${aWall}
variable d1 equal round($d/${aWall})*${aWall}
variable Ly1 equal round(${Ly}/${aWall})*${aWall}
variable Lx1 equal round(${Lx}/${aWall})*${aWall}
#create simulation box
variable lx2 equal ${Lx1}/2
variable ly2 equal ${Ly1}/2
region simbox block -${lx2} ${lx2} -${ly2} ${ly2} 0 0.1 units box
create_box 2 simbox
#####################################################################
#set up potential
mass 1 1.0 #fluid atoms
mass 2 1.0 #wall atoms
pair_style lj/cut 2.5
pair_modify shift yes
pair_coeff 1 1 1.0 1.0 2.5
pair_coeff 1 2 1.0 1.0 1.12246
pair_coeff 2 2 0.0 0.0
neigh_modify exclude type 2 2
timestep ${ts}
#####################################################################
#create atoms
#create wall atoms everywhere
create_atoms 2 box
#define region which is "walled off"
variable dhalf equal ${d1}/2
variable Lhalf equal ${L1}/2
region walltop block -${Lhalf} ${Lhalf} ${dhalf} EDGE -0.1 0.1 &
units box
region wallbot block -${Lhalf} ${Lhalf} EDGE -${dhalf} -0.1 0.1 &
units box
region outsidewall union 2 walltop wallbot side out
#remove wall atoms outside wall region
group outside region outsidewall
delete_atoms group outside
#remove wall atoms that aren't on edge of wall region
variable x1 equal ${Lhalf}-${aWall}
variable y1 equal ${dhalf}+${aWall}
region insideTop block -${x1} ${x1} ${y1} EDGE -0.1 0.1 units box
region insideBot block -${x1} ${x1} EDGE -${y1} -0.1 0.1 units box
region insideWall union 2 insideTop insideBot
group insideWall region insideWall
delete_atoms group insideWall
#define new lattice, to give correct fluid density
#y lattice const must be a multiple of aWall
variable atrue equal ${dens}^(-1/2)
variable ay equal round(${atrue}/${aWall})*${aWall}
#choose x lattice const to give correct density
variable ax equal (${ay}*${dens})^(-1)
#change Lx to be multiple of ax
variable Lx1 equal round(${Lx}/${ax})*${ax}
variable lx2 equal ${Lx1}/2
change_box all x final -${lx2} ${lx2} units box
#define new lattice
lattice custom ${dens} &
a1 ${ax} 0.0 0.0 a2 0.0 ${ay} 0.0 a3 0.0 0.0 1.0 &
basis 0.0 0.0 0.0
#fill in rest of box with bulk particles
variable delta equal 0.001
variable Ldelt equal ${Lhalf}+${delta}
variable dDelt equal ${dhalf}-${delta}
region left block EDGE -${Ldelt} EDGE EDGE -0.1 0.1 units box
region right block ${Ldelt} EDGE EDGE EDGE -0.1 0.1 units box
region pipe block -${Ldelt} ${Ldelt} -${dDelt} ${dDelt} -0.1 0.1 &
units box
region bulk union 3 left pipe right
create_atoms 1 region bulk
group bulk type 1
group wall type 2
#remove atoms that are too close to wall
delete_atoms overlap 0.9 bulk wall
neighbor 0.3 bin
neigh_modify delay 0 every 1 check yes
neigh_modify exclude group wall wall
velocity bulk create $T 78915 dist gaussian rot yes mom yes loop geom
#####################################################################
#set up PUT
#see Evans and Morriss, Phys. Rev. Lett. 56(20) 1986, p. 2172
#average number of particles per box, Evans and Morriss used 2.0
variable NperBox equal 8.0
#calculate box sizes
variable boxSide equal sqrt(${NperBox}/${dens})
variable nX equal round(lx/${boxSide})
variable nY equal round(ly/${boxSide})
variable dX equal lx/${nX}
variable dY equal ly/${nY}
#temperature of fluid (excluding wall)
compute myT bulk temp
#profile-unbiased temperature of fluid
compute myTp bulk temp/profile 1 1 0 xy ${nX} ${nY}
#thermo setup
thermo ${thermo_rate}
thermo_style custom step c_myT c_myTp etotal press
#dump initial configuration
# dump 55 all custom 1 all.init.lammpstrj id type x y z vx vy vz
# dump 56 wall custom 1 wall.init.lammpstrj id type x y z
# dump_modify 55 sort id
# dump_modify 56 sort id
run 0
# undump 55
# undump 56
#####################################################################
#equilibrate without GD
fix nvt bulk nvt temp $T $T ${tdamp}
fix_modify nvt temp myTp
fix 2 bulk enforce2d
run ${equil}
#####################################################################
#initialize the COM velocity and run to achieve steady-state
#calculate velocity to add: V=J/rho_total
variable Vadd equal $J*lx*ly/count(bulk)
#first remove any COM velocity, then add back the streaming velocity
velocity bulk zero linear
velocity bulk set ${Vadd} 0.0 0.0 units box sum yes mom no
fix GD bulk flow/gauss 1 0 0 #energy yes
#fix_modify GD energy yes
run ${stabil}
#####################################################################
#collect data
#print the applied force and total flux to ensure conservation of Jx
variable Fapp equal f_GD[1]
compute vxBulk bulk reduce sum vx
compute vyBulk bulk reduce sum vy
variable invVol equal 1.0/(lx*ly)
variable jx equal c_vxBulk*${invVol}
variable jy equal c_vyBulk*${invVol}
variable curr_step equal step
variable p_Fapp format Fapp %.3f
variable p_jx format jx %.5g
variable p_jy format jy %.5g
fix print_vCOM all print ${dump_rate} &
"${curr_step} ${p_Fapp} ${p_jx} ${p_jy}" file GD.out screen no &
title "timestep Fapp Jx Jy"
#compute IK1 pressure profile
#see Todd, Evans, and Davis, Phys. Rev. E 52(2) 1995, p. 1627
#use profile-unbiased temperature to remove the streaming velocity
#from the kinetic part of the pressure
compute spa bulk stress/atom myTp
#for the pressure profile, use the same grid as the PUT
compute chunkX bulk chunk/atom bin/1d x lower ${dX} units box
#output pressure profile and other profiles
#the pressure profile is (-1/2V)*(c_spa[1] + c_spa[2]), where
#V is the volume of a slice
fix profiles bulk ave/chunk 1 1 ${dump_rate} chunkX &
vx density/mass c_spa[1] c_spa[2] &
file x_profiles ave running overwrite
#compute velocity profile across the pipe with a finer grid
variable dYnew equal ${dY}/10
compute chunkY bulk chunk/atom bin/1d y center ${dYnew} units box &
region pipe
fix velYprof bulk ave/chunk 1 1 ${dump_rate} chunkY &
vx file Vy_profile ave running overwrite
#full trajectory
# dump 7 bulk custom ${dump_rate} bulk.lammpstrj id type x y z
# dump_modify 7 sort id
run ${run}
This diff is collapsed.
This diff is collapsed.
timestep Fapp Jx Jy
2050 -215.835 0.1 -0.002562
2100 -220.455 0.1 -0.0019705
2150 55.212 0.1 -0.0028338
2200 87.052 0.1 -0.0042335
2250 -62.998 0.1 -0.0045646
2300 71.630 0.1 -0.0039858
2350 43.159 0.1 -0.0029771
2400 109.930 0.1 -0.0018522
2450 110.735 0.1 -0.0011188
2500 107.071 0.1 0.0005978
2550 335.449 0.1 0.0010164
2600 159.694 0.1 -0.00015953
2650 6.532 0.1 -0.0004907
2700 65.524 0.1 -0.00093116
2750 79.662 0.1 -0.0033425
2800 69.846 0.1 -0.0055377
2850 122.175 0.1 -0.00721
2900 32.456 0.1 -0.0086166
2950 -85.137 0.1 -0.01107
3000 154.735 0.1 -0.011337
3050 72.979 0.1 -0.0095316
3100 -24.457 0.1 -0.0098708
3150 -0.383 0.1 -0.0094961
3200 132.434 0.1 -0.011524
3250 48.222 0.1 -0.014966
3300 -73.186 0.1 -0.016999
3350 172.062 0.1 -0.018554
3400 106.144 0.1 -0.021202
3450 -22.860 0.1 -0.01949
3500 22.120 0.1 -0.016033
3550 -254.920 0.1 -0.012172
3600 -147.218 0.1 -0.011162
3650 -12.508 0.1 -0.010255
3700 81.846 0.1 -0.0085117
3750 -79.406 0.1 -0.0061294
3800 -34.994 0.1 -0.0026239
3850 94.992 0.1 -0.0015312
3900 -0.345 0.1 -0.0011157
3950 -88.693 0.1 -0.0018929
4000 156.029 0.1 -0.0024547
# Chunk-averaged data for fix velYprof and group file
# Timestep Number-of-chunks Total-count
# Chunk Coord1 Ncount vx
4000 130 18774
1 -19.8462 0 0
2 -19.5385 0 0
3 -19.2308 0 0
4 -18.9231 0 0
5 -18.6154 0 0
6 -18.3077 0 0
7 -18 0 0
8 -17.6923 0 0
9 -17.3846 0 0
10 -17.0769 0 0
11 -16.7692 0 0
12 -16.4615 0 0
13 -16.1538 0 0
14 -15.8462 0 0
15 -15.5385 0 0
16 -15.2308 0 0
17 -14.9231 0 0
18 -14.6154 0 0
19 -14.3077 0 0
20 -14 0 0
21 -13.6923 0 0
22 -13.3846 0 0
23 -13.0769 0 0
24 -12.7692 0 0
25 -12.4615 0 0
26 -12.1538 0 0
27 -11.8462 0 0
28 -11.5385 0 0
29 -11.2308 0 0
30 -10.9231 0 0
31 -10.6154 0 0
32 -10.3077 0 0
33 -10 0 0
34 -9.69231 0 0
35 -9.38462 0 0
36 -9.07692 12.3415 0.126356
37 -8.76923 9.14634 0.119194
38 -8.46154 3.46341 0.0688559
39 -8.15385 7.26829 0.180935
40 -7.84615 9.97561 0.114685
41 -7.53846 6.14634 0.158317
42 -7.23077 7.17073 0.128092
43 -6.92308 8.56098 0.30356
44 -6.61538 7.7561 0.118822
45 -6.30769 6.04878 0.170019
46 -6 8.19512 0.146873
47 -5.69231 8.4878 0.258003
48 -5.38462 7.21951 0.0612577
49 -5.07692 7.14634 0.394221
50 -4.76923 7.34146 0.214609
51 -4.46154 7.90244 0.1583
52 -4.15385 6.36585 0.191919
53 -3.84615 8.04878 0.202891
54 -3.53846 7.2439 -0.00173288
55 -3.23077 7.53659 0.117062
56 -2.92308 6.41463 0.324614
57 -2.61538 7.60976 0.496272
58 -2.30769 8.39024 0.364642
59 -2 6.73171 0.292624
60 -1.69231 7.02439 0.517913
61 -1.38462 8.43902 0.534594
62 -1.07692 7.21951 0.497622
63 -0.769231 6.95122 0.303701
64 -0.461538 8.68293 0.406682
65 -0.153846 7.5122 0.218835
66 0.153846 6.82927 0.189413
67 0.461538 8.26829 0.228409
68 0.769231 7.2439 0.506845
69 1.07692 7.97561 0.154118
70 1.38462 8.26829 0.144882
71 1.69231 6.58537 0.192568
72 2 7.46341 0.360144
73 2.30769 8.95122 0.0112179
74 2.61538 6.58537 0.276061
75 2.92308 6.53659 0.114354
76 3.23077 8.46341 0.0386417
77 3.53846 8 0.0711626
78 3.84615 6.92683 0.203194
79 4.15385 8.4878 0.317789
80 4.46154 7.5122 0.268122
81 4.76923 6.58537 -0.112372
82 5.07692 9.02439 0.115702
83 5.38462 7.41463 -0.067424
84 5.69231 6.07317 0.0626918
85 6 8.34146 -0.0153977
86 6.30769 8.21951 0.281342
87 6.61538 6.29268 0.359939
88 6.92308 8.87805 0.110875
89 7.23077 6.09756 0.134999
90 7.53846 6.65854 0.0841478
91 7.84615 10.8537 0.144519
92 8.15385 5.58537 0.309331
93 8.46154 5.80488 0.103667
94 8.76923 7.60976 0.39288
95 9.07692 12.0244 0.462022
96 9.38462 0 0
97 9.69231 0 0
98 10 0 0
99 10.3077 0 0
100 10.6154 0 0
101 10.9231 0 0
102 11.2308 0 0
103 11.5385 0 0
104 11.8462 0 0
105 12.1538 0 0
106 12.4615 0 0
107 12.7692 0 0
108 13.0769 0 0
109 13.3846 0 0
110 13.6923 0 0
111 14 0 0
112 14.3077 0 0
113 14.6154 0 0
114 14.9231 0 0
115 15.2308 0 0
116 15.5385 0 0
117 15.8462 0 0
118 16.1538 0 0
119 16.4615 0 0
120 16.7692 0 0
121 17.0769 0 0
122 17.3846 0 0
123 17.6923 0 0
124 18 0 0
125 18.3077 0 0
126 18.6154 0 0
127 18.9231 0 0
128 19.2308 0 0
129 19.5385 0 0
130 19.8462 0 0
# Chunk-averaged data for fix profiles and group density/mass
# Timestep Number-of-chunks Total-count
# Chunk Coord1 Ncount vx density/mass c_spa[1] c_spa[2]
4000 32 109675
1 -48.4375 97.7805 0.159561 0.782244 -9.17487 -8.9018
2 -45.3125 100.927 0.187846 0.807415 -9.24302 -9.92813
3 -42.1875 99.0976 0.227036 0.79278 -9.03415 -9.66032
4 -39.0625 101.146 0.243495 0.809171 -8.89515 -9.25314
5 -35.9375 98.7805 0.194616 0.790244 -9.13265 -8.52663
6 -32.8125 97.8049 0.165768 0.782439 -9.26009 -8.52446
7 -29.6875 100.195 0.0758064 0.801561 -9.02933 -8.50733
8 -26.5625 98.4878 0.054432 0.787902 -9.61672 -9.24963
9 -23.4375 99.9268 0.0740914 0.799415 -9.88959 -9.94984
10 -20.3125 99.7561 0.130294 0.798049 -10.2459 -9.39412
11 -17.1875 102.463 0.120168 0.819707 -10.6072 -10.254
12 -14.0625 47.6341 0.208545 0.381073 -9.85715 -10.0799
13 -10.9375 48.1951 0.238051 0.385561 -9.81349 -10.569
14 -7.8125 47.439 0.287107 0.379512 -10.0184 -9.63087
15 -4.6875 48.2439 0.22506 0.385951 -9.83794 -9.6963
16 -1.5625 48.4634 0.208869 0.387707 -9.29366 -10.0114
17 1.5625 46.4878 0.19447 0.371902 -10.2409 -9.84627
18 4.6875 47.2927 0.168034 0.378341 -10.1523 -11.908
19 7.8125 48.6829 0.145552 0.389463 -10.24 -11.0582
20 10.9375 48.8293 0.214036 0.390634 -9.27729 -10.1074
21 14.0625 46.9756 0.267083 0.375805 -9.24833 -9.83182
22 17.1875 97.2683 0.175404 0.778146 -9.64001 -8.61724
23 20.3125 101.146 0.10746 0.809171 -9.33416 -9.82308
24 23.4375 101.927 0.157503 0.815415 -9.76491 -10.1909
25 26.5625 101.024 0.179934 0.808195 -9.72775 -9.98559
26 29.6875 100.976 0.180631 0.807805 -9.33871 -10.0228
27 32.8125 96.4146 0.144418 0.771317 -9.74826 -9.79723
28 35.9375 101.244 0.117224 0.809951 -8.95584 -8.80226
29 39.0625 102 0.10507 0.816 -9.15563 -8.98232
30 42.1875 101.195 0.040236 0.809561 -9.1499 -8.95112
31 45.3125 96.9512 0.0312252 0.77561 -9.20475 -9.0005
32 48.4375 100.244 0.103032 0.801951 -9.16324 -8.77526
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment