extrernal potential

Dear Users and Developers,

I would like to apply a fixed potential [v(x,y,z)] on my atoms which depends on the absolute x, y and z coordinates of the individual atoms. The potential can be expressed with simple functions (exp, cos, sqrt) of the Cartesian coordinates or can be tabulated.

[the potential is defined in eq 3. http://dx.doi.org/10.1038/nnano.2015.106]

Is there a way to apply this external potential to a system by defining analytically or by reading in tabulated form in LAMMPS?

Thank you for your kind answer in anticipation!

Best regards,

Janos

Dear Users and Developers,

I would like to apply a fixed potential [v(x,y,z)] on my atoms which depends on the absolute x, y and z coordinates of the individual atoms. The potential can be expressed with simple functions (exp, cos, sqrt) of the Cartesian coordinates or can be tabulated.

[the potential is defined in eq 3. http://dx.doi.org/10.1038/nnano.2015.106]

Is there a way to apply this external potential to a system by defining analytically or by reading in tabulated form in LAMMPS?

Yes. You can try fix addforce with atom style variables.

Axel

And if it needs to be faster, you could easily write a fix

which encodes your formulas in C code to add force

as a function of the coords of each atom.

Steve

Dear Steve and Axel,

Thank you for the nice solutions!

In case of the C code: is there some minimalistic example available somewhere
(eg. is there an already implemented feature written in the same way in the code)?

Just one remark to make the question more precise: I would need to apply the force on each atom of a given type.

So I hope to implement something like:
add_my_potential 3

where 3 is the atom type identifier.

Thanks in anticipation,
Janos

Any fix (there are many) which defines a post_force() method

is typically adding some force to some atoms. E.g. fix_efield.cpp/h.

In the post_force() method you simply need to do:

loop over atoms:

if atom not in group: continue

compute force on atom at x,y,z and type itype

add force to atom

store an energy contribution (if you wish)

Steve

Dear all, especially dear Axel and Steve,

I have posted here previously about adding external one body potential V(x,y,z) for a system.
There was two suggestion and in the end I took Axel’s suggestion to implement it through
fix addforce and atom-style variables.

When I tried to test it I found that:
a) either I do not understand how to print out the potential energy of the system
b) or fix addforce does not add the energy to the potential energy for some reason
c) I have messed up something in the syntax of adding the potential to the system through “energy”

Please help me find out which is the case! Please note that when I print out the potential
it gives reasonable values, but potential energy with the “pe” variable always gives 0.
I do not ask you to check the details of the potential it is only provided for illustration.

Please find the relevant input bellow.

Thank you for your help in anticipation!

Janos

#input:
include “system.in.init”

#(…)

PARAMETERS

variable pi equal 3.14159
variable b equal 4.83045
variable Ea equal 0.00698237
variable Ec equal 3.6749e-05
variable bb equal 0.423342
variable y0 equal 37.9585

#calculating the potential: PROBABLY NOT IMPORTANT ONLY FUNCTIONS OF x, y and z
variable Axz atom ({Ea}-{Ec}(6.0-4.0cos(2.0*${pi}x/b)*cos(2.0*{pi}z/b/sqrt(3.0))-2.0*cos(4.0*{pi}z/b/sqrt(3.0)))/9.0) variable By atom (exp(-2.0*{bb}(y-{y0})-2.0*exp(-{bb}(y-${y0}))))
variable Vxyz atom (v_Axz
v_By)

#calculating derivatives: PROBABLY NOT IMPORTANT ONLY FUNCTIONS OF x, y and z
variable CuFx atom (-1.0*{Ec}*8.0/9.0*{pi}/b*cos(2.0*{pi}z/b/sqrt(3.0))*sin(2.0*{pi}x/b)*v_By) variable CuFy atom (-1.0*v_Axz*(-2.0*{bb}exp(-2.0{bb}*(y-{y0}))+2{bb}*exp(-1*{bb}(y-{y0})))) variable CuFz atom (-1.0*{Ec}8.0/9.0${pi}/sqrt(3.0)/b*sin(4.0*{pi}*z/sqrt(3.0)/$b)*v_By)

#Apply the force on the Xe atom: PLEASE CHECK THIS PART
fix field Xe addforce v_CuFx v_CuFy v_CuFz energy v_Vxyz

#Printing out quantities: PLEASE CHECK THIS PART
compute ener all reduce sum v_Vxyz
variable e equal c_ener
variable p equal pe
thermo 1
thermo_style custom pe c_ener #this gives 0 and some meaningful number for c_ener
fix extra all print 1 “{p} {e}” file ener.dat #this one does the same

#one note:
#the system is set up with no other potential then the one body V(x,y,z)
#eg in system.in.init

units electron
atom_style full
neigh_modify exclude type 1 1
kspace_style none
atom_modify sort 1 1.0
pair_style none

Dear all, especially dear Axel and Steve,

I have posted here previously about adding external one body potential
V(x,y,z) for a system.
There was two suggestion and in the end I took Axel's suggestion to
implement it through
fix addforce and atom-style variables.

When I tried to test it I found that:
a) either I do not understand how to print out the potential energy of the
system
b) or fix addforce does not add the energy to the potential energy for some
reason
c) I have messed up something in the syntax of adding the potential to the
system through "energy"

d) if you want a fix to add its energy to the total energy, you have
to use fix_modify energy.
it says so explicitly at the end of the documentation for fix addforce

axel.