Hi everyone,
I am using Lammps version 2Aug2023.
I want Lammps not to calculate force at each timestep. Instead, I will impose forces at each timestep. Do you have any hints for me?
I tried imposing forces by ‘extract_atom’ but I dont exactly how it works.
Thank you very much.
Below is code example in PyLammps:
from lammps import lammps
import numpy as np
lmp = lammps()
######################################
# INITIALIZATION
lmp.command('units metal')
lmp.command('dimension 2')
lmp.command('boundary p p p')
lmp.command('atom_style atomic')
######################################
# SIMULATION BOX
lmp.command('region whole block 0 5 0 5 0 10')
lmp.command('create_box 1 whole')
lmp.command('create_atoms 1 single 4 4 5')
lmp.command('create_atoms 1 single 3 1 5')
lmp.command('create_atoms 1 single 0.2 4 5')
lmp.command('create_atoms 1 single 3.5 3.5 5')
lmp.command('create_atoms 1 single 0.2 2 5')
######################################
# ATOM DEFINITION
lmp.command('mass 1 26.98')
lmp.command('neighbor 0 bin')
lmp.command('neigh_modify every 1 check no')
######################################
# DEFINE INTERATOMIC POTENTIAL
lmp.command('pair_style lj/cut 10')
lmp.command('pair_coeff * * 0.01 0.01')
######################################
# EQUILIBRATION
lmp.command('timestep 0.001')
lmp.command('velocity all create 300 12345 mom yes rot no')
lmp.command('fix 1 all nvt temp 300 300 1 ')
lmp.command('run 1')
pos = lmp.numpy.extract_atom('x')
force = lmp.numpy.extract_atom('f')
f = lmp.extract_atom('f')
pred_force = np.random.rand(5,3)
for i in range (force.shape[0]):
f[i][0], f[i][1], f[i][2] = pred_force[i][0], pred_force[i][1], pred_force[i][2]
lmp.command('run 1')