LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
Re: [lammps-users] Setting a time-dependent dipole moment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lammps-users] Setting a time-dependent dipole moment


From: Axel Kohlmeyer <akohlmey@...24...>
Date: Mon, 24 Jul 2017 15:27:49 -0400

On Mon, Jul 24, 2017 at 1:16 PM, Antonio Ortiz <aortiza@...7014...> wrote:
> Hello,
>
> I'm trying to set a time dependent dipole moment for a pair of particles by
> calculating a variable with:
>
> variable Field atom time*1e-9
>
> and then I write:
>
> set group Atoms dipole 0 0 v_Field
>
> The problem is that instead of assigning the value of the calculated
> variable to the z component of the dipole moment, it assigns zero. Even if I
> set the initial value to something other than zero, the set command will put
> it back to zero.

you are misunderstanding how the set command works. set is
*instantaneous*, i.e. it will take the current value and assign it.
it will *not* associate an atom property with an expression during the
simulation.
if you want something like that, you would have to program a new fix
style, that overwrites the dipole components during the simulation in
a similar fashion as fix setforce overwrites the forces. in that case
the variable expression is evaluated at every step *during* the run
and the resulting value assigned.

the other examples you describe all the same issue. the problem is not
really a LAMMPS problem but a matter of PEBCAC.

axel.

>
> However if I dump the value of v_Field, it is being updated every loop.
> Also, if I substitute time for xlo, the calculated value is correctly set to
> the dipole moment. The same problem arises if I try to set the position to a
> time dependent variable.
>
> I'm sending a working example.
>
> Thanks in advance,
> Antonio Ortiz.
>
> ----- LAMMPS Input File -----
> units micro
> atom_style hybrid sphere dipole bond
> boundary s s p
> dimension 3
> neighbor 4.0 nsq
> pair_style lj/cut/dipole/cut 20
>
> read_data TimeDependentInput.data
>
> group Atoms type 1
> mass * 1
>
> timestep 10000
>
> variable thermoname equal time/1e9
> variable Field atom time*1e-9
>
> set group Atoms dipole 0 0 v_Field
>
> dump 3 all custom 10 TimeDependentField.lammpstrj id type x y z v_Field muz
> thermo_style custom step atoms v_thermoname
> thermo 1000
>
> run 6000
>
> ----- TimeDependentInput.data File -----
> 4 atoms
> 2 atom types
> -30.00 30.00 xlo xhi
> -30.00 30.00 ylo yhi
> -1.50 1.50 zlo zhi
>
> Atoms
>
>      1 2 15.00 0.00 0.000000 10.30 0.0017 0.0     0    0     0 1
>      2 2 -15.00 0.00 0.000000 10.30 0.0017 0.0     0    0     0 2
>      3 1 15.01 0.00 0.014681 10.30 0.001678 0.0 0.0 0.0     0.002 1
>      4 1 -15.01 0.00 0.016334 10.30 0.001678 0.0 0.0 0.0     0.002 2
>
> PairIJ Coeffs
>
> 1 1 0.0 0.0 0.0 60.000000
> 1 2 0.0 0.0 0.0 0.0
> 2 2 0.0 0.0 0.0 0.0
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> lammps-users mailing list
> lammps-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lammps-users
>



-- 
Dr. Axel Kohlmeyer  akohlmey@...24...  http://goo.gl/1wk0
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.