[lammps-users] lammps-question regarding periodic boundary conditions

Hello every one
I apologize in advance for the very basic/simple question but i did not find something similar in the archive.
say that i want to simulate a very basic chain of harmonic oscillators with periodic boundary conditions ,if i have a chain of N particles then u_{N+1]}=u_{1} but in lammps the periodic boundary condition is that if the atom moves outside the simulation box then it is returned on the other side ,so what i did was simply use a bond style harmonic when in my input file i connected the N atom with the first atom also but then the system does not conserve energy ,i am probably missing here something really basic can any one help me with this
(mean while ill keep reading in frenkel and smit and rappaport maybe ill catch my mistake there)
thanks a lot in advance !
              Tal

PBC are defined with the boundary command. Your input
data file can define bonds that cross the periodic boundary
(e.g. atom N bonded to atom 1). There should be no
issue with this. If you are not conserving energy, it is likely
some other issue with your model.

Steve

Hi Steve!
first of all thanks you were right i prepared the system with a lattice that of [0 L] and that way the last bond was huge and blew up .
i have one more question thou when i look at the energy per particle of such a system i see that the energy of the first and last particle is half of that of the other particles i.e lets say that each particle has a potential energy of 4 then particle N and 1 has 2 does lammps calculate the energy on the edges of the lattice by half since its the same atom ?
thanks a lot in advance and again i apologize for the trivial question
Tal
Steve Plimpton wrote:

How are you computing the energy per atom? If it is with
the compute pe/atom command (and dumping it), then
LAMMPS will treat the periodic BC correctly.

Steve

Hi Steve
its not even that its even simpler and i still don’t get energy conservation .
thanks a lot in advance !!
Tal

my input file is :

#simulation for harmonic chain

units lj
dimension 2
boundary p p p

atom_style bond

read_data bonds.txt

mass 1 1.0

velocity all create 0.1 4928459 rot no dist gaussian

bond_style harmonic
bond_coeff 1 1 16
neighbor 0.3 nsq
neigh_modify delay 5
atom_modify sort 1 1

fix NVE all nve
fix Z all enforce2d
fix 1Dy all lineforce 1 0 0

dump 1 all xyz 100 data.xyz
thermo 250
thermo_style custom pe ke emol etotal
run 10000

and for 10 atoms the bonds.txt file looks like :

BONDS DATA

10 atoms
10 bonds

1 atom types
1 bond types

0 2000 xlo xhi
0 0.25 ylo yhi
0 0.25 zlo zhi

Atoms

1 1 1 16 0 0
2 1 1 32 0 0
3 1 1 48 0 0
4 1 1 64 0 0
5 1 1 80 0 0
6 1 1 96 0 0
7 1 1 112 0 0
8 1 1 128 0 0
9 1 1 144 0 0
10 1 1 160 0 0

Bonds

1 1 1 2
2 1 2 3
3 1 3 4
4 1 4 5
5 1 5 6
6 1 6 7
7 1 7 8
8 1 8 9
9 1 9 10
10 1 10 1

Steve Plimpton wrote:

You didn't answer my previous questions. How do
you measure energy conservation, either global
or per-atom?

Steve

Hi Steve
i measure the energy globally with the thermo command
         Tal
Quoting Steve Plimpton <[email protected]>:

A global measure makes no sense with regard to your initial question:

i have one more question thou when i look at the energy per particle
of such a system i see that the energy of the first and last particle
is half of that of the other particles i.e lets say that each particle
has a potential energy of 4 then particle N and 1 has 2 does lammps
calculate the energy on the edges of the lattice by half since its the
same atom ?
thanks a lot in advance and again i apologize for the trivial question

Steve

Hi Steve
even when i compute the per atom energy and sum it up i still don’t get conservation ,am i missing something here ?
Tal
Steve Plimpton wrote:

If you sum the per-atom energy you should get the global
energy. As to why it is not being conserved, there could
be many reasons: too big a timestep, unrelaxed system,
using a potential with a cutoff, long-time drift. etc. These
are all MD issues, not LAMMPS issues.

Steve