[lammps-users] CaF2 molecular dynamic

Dear all,

I want to calculate dynamic of CaF_2 bulk system.
The compound has FCC symmetry with Ca atom in (0,0,0) position
and F atoms in (1/4,1/4,1/4) and (-1/4,-1/4,-1/4) positions.
The input file follows bellow. The result looks reasonable, except
atoms close to the boundary jumps from one and of the box to
another. Is it normal or I did something wrong in the input file.
Thank you in advance,
German

# 3d metal

units metal

atom_style hybrid charge

boundary p p p

#lattice sc 5.46

lattice sc 5.4413

region box block 0 1 0 1 0 1

create_box 3 box

create_atoms 1 single 0 0 0
create_atoms 1 single 0.5 0.5 0
create_atoms 1 single 0.5 0 0.5
create_atoms 1 single 0 0.5 0.5
create_atoms 2 single 0.25 0.25 0.25
create_atoms 2 single 0.75 0.75 0.25
create_atoms 2 single 0.75 0.25 0.75
create_atoms 2 single 0.25 0.75 0.75
create_atoms 3 single 0.75 0.75 0.75
create_atoms 3 single 0.75 0.25 0.25
create_atoms 3 single 0.25 0.75 0.25
create_atoms 3 single 0.25 0.25 0.75

mass 1 40.0
mass 2 19.0
mass 3 19.0

set atom 1 charge 2.0
set atom 2 charge 2.0
set atom 3 charge 2.0
set atom 4 charge 2.0
set atom 5 charge -1.0
set atom 6 charge -1.0
set atom 7 charge -1.0
set atom 8 charge -1.0
set atom 9 charge -1.0
set atom 10 charge -1.0
set atom 11 charge -1.0
set atom 12 charge -1.0

# 1 - Ca, 2,3 - F

pair_style buck/coul/long 15.0

pair_coeff 1 1 0.0 1.0 0.0
pair_coeff 1 2 674.3 0.336 0.0
pair_coeff 1 3 674.3 0.336 0.0
pair_coeff 2 2 1808.0 0.293 109.1
pair_coeff 2 3 1808.0 0.293 109.1
pair_coeff 3 3 1808.0 0.293 109.1

replicate 2 2 2

kspace_style pppm 0.0001

velocity all create 3.0 87287

neighbor 0.3 bin

neigh_modify every 20 delay 0 check no

fix 1 all nve

#dump id all xyz 10 dump.xyz

compute myKE all ke/atom

compute myPE all pe/atom

dump id all custom 10 dump.xyz tag type x y z vx vy vz c_myKE c_myPE

thermo 50

run 250

That's what periodic boundaries mean. Atoms
move across the boundary as if it wasn't there.

Steve

Thank you Steve,

1) It does not look like result of periodic boundaries.
In order to demonstrate what is going on I've attached
figure with atoms distribution at zero stem and at step 250.
Some of the atoms on the boundary removed and attached on the other
side out of convenient box.
The velocities are initialized at temperature equals 3 K.

2) How I can initialise charge for the type of atoms?
I've initialised it for each atom in the initial unit cell.

3) I need to calculate heat flux in this system.
the expression for the heat flux is
J = sum_i v_i epsilon_i + 1/2 sum_pairs F_ij r_ij . (v_i+v_j)
This problems already discussed by Philip Howell.
How I can extract pair forces F_{ij}

Thank you in advance.

German

step_0.GIF

step_250.GIF

1) Why is that not PBC?
2) see the set command, or put the atoms in a data file with a charge
on every atom
3) you'd have to write your own fix to compute something like that, and
    have it loop over the neighbor list and call pair->single() to get IJ force

Steve

Thank you Steve,

I've used compute_group_group as an example for calculation of heat flux.
The modified files: style.h, compute_hf_atom.h and compute_hf_atom.cpp
(see attachments)
The potential energy calculated using force->pair->eatom() is in
agreement with result of
compute_pe_atom.cpp, this no wonder. There as then I try to calculate
potential energy
using return from eng =
pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair), the
result is
absolutely different. Is the value returned by pair->signle() single
pair contribution to
potential energy?

Thank you in advance,
German

style.h (9.27 KB)

compute_hf_atom.h (1.19 KB)

compute_hf_atom.cpp (8.52 KB)

What pair potential are you doing this for?

Steve

The pair potential is Buckingham potential + Coulombic potential

pair_style buck/coul/long 10.0

German

For pair buck/coul/long, it looks like single() should do
the same thing as the per-atom logging. So long as
you recognize that there will be no long-range component
to the energy, just like compute pe/atom. I.e. you can't
compare total energy to the output of "pe" by the thermo
command, which includes the long-range part (for the entire
system).

To debug, I would setup a 2-atom or 3-atom test, see what
compute pe/atom stores and your single() calls, and put
in print statements if they are different.

Steve

I run system with one bcc unit cell, 2 atoms

the input is

# 3d Lennard-Jones melt

units lj
atom_style atomic

boundary f f f
lattice bcc 0.8442
region box block 0 1 0 1 0 1
create_box 1 box
create_atoms 1 box
mass 1 1.0

velocity all create 0.1 87287

pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5

neighbor 0.3 bin
neigh_modify every 20 delay 0 check no

fix 1 all nve

compute myPE all pe/atom
compute myHF all hf/atom

dump id all custom 10 dump.xyz type x y z vx vy vz c_myHF c_myPE

thermo 10

run 50

After few iterations dump file contains

ITEM: ATOMS
1 0.0178879 -0.00324704 0.00886676 0.367718 -0.0546018 0.187458
-0.412944 -0.499613
1 0.64866 0.669795 0.657681 -0.367718 0.0546018 -0.187458 -0.412944
              -0.499613

there last column corresponds to potential energy of each atom

there as pair->signle() single pair contribution to potential energy gives

-0.999227
0.00000

by the way 0.999227/2=0.4996135
I also do not understand why number of neighbors for the first atom in
the sum of pair->singe() equal 1 ,
but for the second atom 0?

This is right for more complicate systems too. I tried LJ fcc with
periodic boundary conditions.
the number of neighbors for different atoms is different. Sum of
energies over atoms in the unit cell
calculated from pair->single and from compute pe/atom is the same, but
contributions from separate atoms
are different.

Steve, do you understand what I'm doing wrong?

Thank you,
German

Steve, do you understand what I'm doing wrong?

no, sorry, I don't even understand what you're asking.

The total PE is the sum of the per-atom PE, and you
say that's correct. You talk about pair->single() but
neither of those quantities are computed via pair->single().
So what do you think LAMMPS is not doing correctly?

Steve

I'm sorry.

Now from the beginning.

I would like to insert computation of heat flux to the code.

The expression for heat flux looks like
J = sum_i v_i epsilon_i + 1/2 sum_pairs F_ij r_ij . (v_i+v_j).

You recommended me to use pair->single() function.

In order to check if I use it right I compare potential energy per atom
calculated by
1) compute_PE_atom
and

2) run over list->firstneigh for each atom
and eng = pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair)

The result is different.

As I can understand it because the list of neighbors I use is for i>j
so for the system with four atoms, single fcc cell,
first atom 0 has neighbors 1, 2, 3,
second atom 1 - 2,3,4 and the last one no neighbors.
If I summarize potential energy calculated for all atoms the sum is
the same for
both methods.

Question: there I can take "correct" list of atoms neighbors?

Thank you,
German

PS: I've attached compute_hf_atom.cpp file

compute_hf_atom.cpp (9.02 KB)

The standard neigh list in LAMMPS only stores the i,j pair once.
It might be with I, it might be with J. The compute pe/atom
uses energy tallied by pair and other styles that takes account
of this when eng is assigned to atoms.

If you use pair->single() with the neigh list, you will have to
worry about that also. E.g. assign half the result to each
atom, and worry about when atom J is on another proc.

Steve

Thank you Steve.

Just remind, that I would like to insert computation of heat flux to the code.

The expression for heat flux looks like
J = sum_i v_i epsilon_i + 1/2 sum_pairs F_ij r_ij . (v_i+v_j).

I've programmed this expression and it works fine if I use one processor.
In the calculations with few processors it gives NaN values for heat flux.

I would really appreciate if you can take a look at attached files
compute_hf.cpp
and compute_hf.h

Thank you,
German

compute_hf.cpp (9.44 KB)

compute_hf.h (1.22 KB)

Sorry - I can't really debug other people's code. I'd put
in some print statements and figure out what calculation
is blowing up on multiple procs.

Steve