About LAMMPSFixMove python class

Hi, everyone,

i have a question about LAMMPSFixMove python class.

my group’ve developed a new integration algorithm and want to make it by LAMMPSFixMove python class. The method may get involved in computing force for multiple times. the method is shown as follows (details):

the displacement of the method expression is:

X_{n-1} = X_N + \frac{1}{2n-1} \Big(X'_N\Delta t - \frac{1}{2n}\frac{\nabla_X U(X_n)}{M}(\Delta t)^{2}\Big), \quad n\ \rm{for}\ N\ to\ 1

where X_0, X_N, X_N' denote X(a + \Delta t), X(a), X’(a) respectively. According to the definition of derivative, the part of velocity of this method can be expressed as:

\begin{equation} \left\{ \begin{aligned} X_{n-1} ={} & X_N + \frac{1}{2n-2} \Big(X'_N\Delta t - \frac{1}{2n-1}\frac{\nabla_X U(X_n)}{M}(\Delta t)^{2}\Big), & \quad n\ \rm{for}\ N\ to\ 2 \\ X'_0 ={} & X'_N - \frac{\nabla_X U(X_1)}{M}\Delta t, & \quad n = 1 \end{aligned} \right. \end{equation}

where X'_0 denotes X'(a + \Delta t).

but i don’t know how to implement calling force multiple times, i would appreciate it if you reply to me.

LAMMPS’ code infrastructure is built around the velocity Verlet time integration scheme. It also supports r-RESPA, but that is compatible since a 1-level r-RESPA is identical to velocity Verlet.
See: 4.7. How a timestep works — LAMMPS documentation

Thus, the “natural” way to add a new integration scheme would be to write a new integration class in C++. Writing something like this in Python would require creating a whole new set of library calls to the C-library interface and then add the corresponding Python wrappers, so that the velocity Verlet pseudo-core from the page referenced above could be implemented in Python.

There are some fixes written in C++ that support multiple force evaluations by repeating the relevant steps from the time integration process, but that can be quite complex and is not compatible with all functionality in LAMMPS.

Thank you, i’m read this chapter. the method is similar to the following process:

loop over M timesteps:
  for i 1 to N: # add 
    if timeout condition: break
    ev_set()
  
    fix->initial_integrate()
    fix->post_integrate()
  
    nflag = neighbor->decide()
    if nflag:
      fix->pre_exchange()
      domain->pbc()
      domain->reset_box()
      comm->setup()
      neighbor->setup_bins()
      comm->exchange()
      comm->borders()
      fix->pre_neighbor()
      neighbor->build()
      fix->post_neighbor()
    else:
      comm->forward_comm()
  
    force_clear()
    fix->pre_force()
  
    pair->compute()
    bond->compute()
    angle->compute()
    dihedral->compute()
    improper->compute()
    kspace->compute()
  
    fix->pre_reverse()
    comm->reverse_comm()
  
    fix->post_force()
    fix->final_integrate()
    fix->end_of_step()
  
  if any output on this step:
    output->write()

# after loop
fix->post_run()

Our aims is that the method is compatible for all functionality in LAMMPS. But so far the method only use LAMMPS python as “force” engine and run simulation under NVE condition.

Anyway, thank you so much for your reply. We would try other ways to implement this method in LAMMPS.