Rotating time dependent electric field

Dear Lammps community,

I would like to apply a time dependent rotating electric field in the x-y direction, (Ecos(wt), Esin(wt), 0) and have generated sin and cos variables to then put into the fix efield command.

The relevant part of my Lammps script is as shown below:

---------------------------------------------------------------------------------------------------------------------------

timestep 1.0
variable E equal 0.184
variable Ex equal $Ecos(0.00001dtstep) # Frequency 0.00001 dtstep is time variable
variable Ey equal E*sin(0.00001*dt*step) # Frequency 0.00001 dt*step is time variable fix fxfld all efield {Ex} ${Ey} 0.0

check the time varying field

variable time equal dt*step
fix savpos all print 10 “{time} {Ex} ${Ez}” file field.dat # writes time varying field to a file

-------------------------------------------------------------------------------------------------------------------------------

My field.dat file gives valid oscillating efield as I wanted, but the system response is as if I am applying a DC field in x and y direction.

On the manual I read we can apply a time varying field by simply using a variable in the efield command. I this correct, and how do I implement this correctly?

Kind regards

David

2015-07-12 4:22 GMT+02:00 David Ostler <[email protected]...>:

Dear Lammps community,

I would like to apply a time dependent rotating electric field in the x-y
direction, (E*cos(w*t), E*sin(w*t), 0) and have generated sin and cos
variables to then put into the fix efield command.

The relevant part of my Lammps script is as shown below:
#
---------------------------------------------------------------------------------------------------------------------------
timestep 1.0
variable E equal 0.184
variable Ex equal $E*cos(0.00001*dt*step) # Frequency 0.00001
dt*step is time variable
variable Ey equal E\*sin\(0\.00001\*dt\*step\) \# Frequency 0\.00001 dt\*step is time variable fix fxfld all efield {Ex} ${Ey} 0.0

# check the time varying field

variable time equal dt*step
fix savpos all print 10 "\{time\} {Ex} ${Ez}" file field.dat
# writes time varying field to a file
#
-------------------------------------------------------------------------------------------------------------------------------

My field.dat file gives valid oscillating efield as I wanted, but the
system response is as if I am applying a DC field in x and y direction.

On the manual I read we can apply a time varying field by simply using a
variable in the efield command. I this correct, and how do I implement this
correctly?

I think the problem is using ${} in the fix definition. Using this
construction expands the variable it encloses to the value it should have
at that specific point in time. (you can see this in the log.lammps file)
So you're supplying a constant to the fix command. You should use v_name
instead, which axtually passes the variable *name" to the fix, allowing it
to use the instantaneous variable value at every time step.

Kristof

Hi Kristof,

Thank you for your help, that has solved my problem.

kind regards

David