Hello everyone,
Thank you for sharing valuable information and insights here. I am using LAMMPS (29 Aug 2024), KOKKOS mode with Kokkos version 4.3.1 to iteratively adjust bond lengths between specific pairs of atoms. For each pair of atoms, I want to compute the displacement vector, normalize it, and use it to incrementally move the atoms from each other over a set number of steps.
However, I’m running into an error when I try to reference atoms & coordinates using variables and applying them in the displace_atoms move
command. I’ve tried different ways to define these variables, but I’ve continued receiving syntax errors. I would greatly appreciate your guidance on where my coding may be incorrect.
variable atom1_1 equal 190
variable atom1_2 equal 198
...variable atom_1_30 equal 136
variable atom_2_1 equal 125
...variable atom_2_30 equal 189
# Set up iteration variables for adjustment
variable npairs equal 30
variable steps equal 28
variable dz equal 0.2
# Iterative bond adjustment
label step_loop
variable s loop ${steps}
# Loop over pairs
label pair_loop
variable p loop ${npairs}
# Define atom indices for the current pair
variable i equal v_atom1_${p}
variable j equal v_atom2_${p}
# Clear and define atom_i and atom_j groups
group atom_i id ${i}
group atom_j id ${j}
# Compute positions for atom_i and atom_j
compute pos_i atom_i property/atom x y z
compute pos_j atom_j property/atom x y z
# Variables to access the x, y, z coordinates for each atom
variable x_i equal c_pos_i[1]
variable y_i equal c_pos_i[2]
variable z_i equal c_pos_i[3]
variable x_j equal c_pos_j[1]
variable y_j equal c_pos_j[2]
variable z_j equal c_pos_j[3]
# Calculate distance squared
variable dist_squared equal ((${x_i}-${x_j})^2+(${y_i}-${y_j})^2+(${z_i}-${z_j})^2)
# Calculate distance
variable dist equal sqrt(dist_squared)
# Calculate displacements
variable dx equal (${x_i}-${x_j})
variable dy equal (${y_i}-${y_j})
variable dz equal (${z_i}-${z_j})
# Normalize the displacement vector components
variable nx equal ${dx}/${dist}
variable ny equal ${dy}/${dist}
variable nz equal ${dz}/${dist}
# Set a fixed displacement distance (dz)
variable displacement equal 0.2
# Final displacement values along each component
variable disp_x equal ${displacement}*${nx}
variable disp_y equal ${displacement}*${ny}
variable disp_z equal ${displacement}*${nz}
# Displace atoms using calculated values
displace_atoms atom_i move ${disp_x} ${disp_y} ${disp_z} units box
displace_atoms atom_j move -${disp_x} -${disp_y} -${disp_z} units box
# Minimization and dump for each step..
next s
jump SELF step_loop
uncompute pos_i
uncompute pos_j
next p
jump SELF pair_loop
# Output thermodynamic information```