Dear Lammps users,
Please help me to apply a simple oscillating electric field. What should be the code for this?
Dear Lammps users,
Please help me to apply a simple oscillating electric field. What should be the code for this?
Thankyou for replying. I went through these pages. I am trying to apply a field of this formula: 0.002sin(wt) where w is the angular frequency and t is the time elapsed.
The code I am using goes like:
timestep 0.1
variable E equal 0.002
variable Ex equal $Ecos(5t)
variable Ey equal $Esin(5t)
fix 4 all efield v_Ex v_Ey 0.0
however, I dont understand how i should represent the time t in my code. Surely the code doesn’t understand what t means. Please see if you can help here
In equal style variables you have access to all “thermo” properties: thermo_style command — LAMMPS documentation
People usually use step
with a corresponding scaling factor for properties that vary during a simulation, but it may work with time
as well (if you don’t need multiple run
sections).
This is my modified codeblock:
thermo_style custom step temp pe lx ly lz press density
#electric field
timestep 0.1
variable E equal 0.002
variable Ex equal $Ecos(5time)
variable Ey equal $Esin(5time)
fix 4 all efield v_Ex v_Ey 0.0
I am getting this error while running it:
“Must use variable energy with fix efield (…/fix_efield.cpp:220)”
I tried fixing it by googling this error but didn’t find any leads.
Kindly let me know if you have an idea about this, thanks
Have you checked the fix efield documentation?
Thankyou, it worked now
Can you share how did you fix this ERROR?