Dear LAMMPS users,
I tried to use LAMMPS to create bonds on a solid
(I know there might be better ways to do it as well, but why not?)
and i found that if the crystal is unperturbed and hence, the atoms lie at their
perfect positions the fix bond/create command does not work
since it creates less bonds than desired.
I assume that when the algorithm tries to create a new bond in an atom
but it detects multiple neighbors at the exact same distance it cant
decide which pair to chose and it skips the current atom.
I found a quick “hacky” solution to overcome this issue that can
be summarized as follows:
- Apply a small random perturbation to distort the crystal.
- Create the bonds
- Reverse the applied perturbation
My solution works fine although i had to make a random generator
since i couldn’t figure out how to reset the seed during the run.
Below i post an excerpt of my code in case anyone finds it useful:
49 # Parameters
50 group GAt id 1 # initialize group
51 variable ampl equal 0.000001 # max displacement
52 variable aa equal 1664525 # LCG rand gen parameter
53 variable mm equal 4294967296 # LCG rand gen parameter
54 variable cc equal 1013904223 # LCG rand gen parameter
55
56 # Apply the perturbation
57 variable rseed equal 123456789
58 variable nid loop (count(all))
59 label loopApply
60 group GAt clear
61 group GAt id {nid}
62 variable rseed equal ({rseed}*{aa}+{cc})%{mm}
63 variable rnd equal {rseed}/{mm}
64 displace_atoms GAt move 0 0 (v_ampl*v_rnd) units box
65 next nid
66 jump SELF loopApply
67
68 # Generate the bonds
69 fix FGenBond GSolid bond/create 1 1 1 3.0 2 iparam 0 1 jparam 0 1
70 thermo 10
71 run 200
72
73 # Reverse the perturbation
74 variable rseed equal 123456789
75 variable nid loop (count(all))
76 label loopReverse
77 group GAt clear
78 group GAt id {nid}
79 variable rseed equal ({rseed}{aa}+{cc})%{mm}
80 variable rnd equal {rseed}/{mm}
81 displace_atoms GAt move 0 0 (-v_amplv_rnd) units box
82 next nid
83 jump SELF loopReverse
84
85 # Done
86 write_data restart.data
87 quit
Also for this to work, one has to include the following in the header of
the data file.
[Set Number] extra bond per atom
[Set Number] extra special per atom
For some reason Number had to be larger than 87 for this to work.
So im curious, is there a way to reset the seed within the script?
Also is this a bug or i did something wrong in the first place?
Best Regards,
A. Sgouros