When I use REAXFF and oscillate electric field, ERROR happen

Hi lammps-user:
when I use REAXFF and oscillate electric field, a error happen. The following is my code about oscillate electric field and reaxff_setting:

#–this part is about oscillate electric field–#
variable E0 equal 1
variable f equal 1e14
variable e equal v_E0sin(2PIv_ftime*1e-15)

#–this part is about QEQ–#
fix ReaxQeq all qeq/reaxff 1 0.0 10.0 1e-6 reaxff

#–this part is about EF_setting–#
fix fxef all efield 0 0 v_e

The above is key code about this problem, if needed, the whole code will upload.
When I run the code, the error message " ERROR: Cannot (yet) use fix qeq/reaxff/omp with variable efield (src/REAXFF/fix_qeq_reaxff.cpp:408)" happened.

IF I use code fix fxef all efield 0 0 ${e}, there is no error happen.
BUT the oscillate electric field seems no work, because I compare two situation(1. fix fxef all efield 0 0 ${e} 2. NO fix fxef all efield 0 0 ${e}), the temp’s change is the same.
SO what way to solve this problem, THANK.

This is good question. Maybe someone can help you.

As the error message indicates, you cannot use ReaxFF with an oscillating electric field. Full stop.

To understand the failure of your “workaround”, you just have to study the documentation of the variable command. There is a big difference between using a variable reference (v_name), when a command offers the option to evaluate a variable instead of a constant value and using variable expansion during the input file processing (${name}).

THANKS @akohlmey , I have a “tupid” wat to solve Oscillate EF and reaxff.
I write a loop, include fix efield.
so In a very small amount of time, EF can be seen as constant.
But before some step, the value will change.
The code like this:
" variable a loop 10
label loop_start
fix xef all efield 0 0 ${a}
run 100
unfix fxef
next a
jump SELF loop_start

I mean, if you’re going to do it, you might as well do it:

variable q atom q
variable efz atom v_q*v_zfield
fix efield all addforce 0 0 v_efz
1 Like

That is not the same here, because with ReaxFF the electric field is also considered during charge equilibration.

Please have a look at the ‘every’ keyword of the ‘run’ command.

1 Like

I’ve never ran a ReaxFF simulation so someone else will have to test this (and GitHub’s API is down / weird right now). @WildonCao do you know how to apply a patch and recompile?

efield-reaxff-varstyle.patch (5.1 KB)

(dev question: with this, a step with qeq/reaxff + variable efield ends up updating the efield variables twice, once in pre_force and once in post_force, including the modify->clear/addstep wrapping. I’m assuming that’s meant to happen and it’s okay when it does.)

1 Like

I have not been exposed to any code changes before.

This patch has shown me hope, hoping that it can continue my research.

could you share this project’s address

Sorry, unless you recompile LAMMPS yourself or get someone to help you do it, there is no way you can use these changes in the near term. :slight_smile:

:sob: :sob: :sob: :sob: :sob: :sob: :sob: :sob: :sob: :sob: :sob:

hi @srtee , could you share the address of document, i want to learn more about it.

@srtee this patch looks plausible, I think it would be worth submitting a PR on Github.

Thanks, been a bit too busy to fix it up but I will soon. There’s one main issue which is that efield with atom-style variable should patch in via the user-defined energy (not force dot displacement – since that only works for spatially uniform fields) and error out if that isn’t given. I’d also need to finish the documentation changes where needed. Can certainly submit within the week.

1 Like

I compared this patch (I have patched to my lammps) and my “stupid loop way” to add ef, the temp has the same change but a little diffluent.
If you have more thorough found, pls let me know, THANKS. @srtee