more refactoring of MDI engine

This commit is contained in:
Steve Plimpton
2022-03-16 17:46:01 -06:00
parent 8d341e0714
commit cf06f71514
5 changed files with 542 additions and 332 deletions

View File

@ -206,14 +206,14 @@ void FixMDIAimd::post_force(int vflag)
f[i][2] += buf3[3*ilocal+2] * mdi2lmp_force;
}
// optionally request energy from MDI engine
// optionally request potential energy from MDI engine
// divide by nprocs so each proc stores a portion
if (eflag_global) {
ierr = MDI_Send_command("<ENERGY",mdicomm);
if (ierr) error->all(FLERR,"MDI: <ENERGY command");
ierr = MDI_Send_command("<PE",mdicomm);
if (ierr) error->all(FLERR,"MDI: <PE command");
ierr = MDI_Recv(&engine_energy,1,MDI_DOUBLE,mdicomm);
if (ierr) error->all(FLERR,"MDI: <ENERGY data");
if (ierr) error->all(FLERR,"MDI: <PE data");
MPI_Bcast(&engine_energy,1,MPI_DOUBLE,0,world);
engine_energy *= mdi2lmp_energy / nprocs;
}

View File

@ -49,6 +49,8 @@ int FixMDIEngine::setmask()
void FixMDIEngine::setup(int vflag)
{
// engine is now at FORCES node
mdi_engine->engine_node("@FORCES");
}
@ -56,6 +58,8 @@ void FixMDIEngine::setup(int vflag)
void FixMDIEngine::post_integrate()
{
// engine is now at COORDS node for MD
mdi_engine->engine_node("@COORDS");
}
@ -63,6 +67,8 @@ void FixMDIEngine::post_integrate()
void FixMDIEngine::min_pre_force(int vflag)
{
// engine is now at COORDS node for minimizer
mdi_engine->engine_node("@COORDS");
}
@ -70,6 +76,8 @@ void FixMDIEngine::min_pre_force(int vflag)
void FixMDIEngine::post_force(int vflag)
{
// engine is now at FORCES node for MD
mdi_engine->engine_node("@FORCES");
}
@ -77,6 +85,8 @@ void FixMDIEngine::post_force(int vflag)
void FixMDIEngine::min_post_force(int vflag)
{
// engine is now at FORCES node for minimizer
mdi_engine->engine_node("@FORCES");
}
@ -84,5 +94,7 @@ void FixMDIEngine::min_post_force(int vflag)
void FixMDIEngine::end_of_step()
{
// engine is now at ENDSTEP node for MD
mdi_engine->engine_node("@ENDSTEP");
}

View File

@ -98,7 +98,14 @@ int MDI_Plugin_init_lammps()
lmp = lammps_open(mdi_argc, mdi_argv, mpi_world_comm, nullptr);
else
lmp = lammps_open_no_mpi(mdi_argc, mdi_argv, nullptr);
// process the specified input script
// must contain "mdi engine" command
lammps_file(lmp, filename);
// shut down the plugin
lammps_close(lmp);
return 0;

File diff suppressed because it is too large Load Diff

View File

@ -35,8 +35,10 @@ class MDIEngine : public Command {
void engine_node(const char *node);
private:
int lmpunits; // REAL or METAL or NATIVE
int root; // 1 for proc 0, otherwise 0
int lmpunits; // REAL or METAL or NATIVE
int root; // 1 for proc 0, otherwise 0
int enable_fix; // 1 if mdi engine command asked for node support
// state of MDI engine
@ -59,8 +61,16 @@ class MDIEngine : public Command {
int nbytes; // NBYTES command value used by other commands
// @INIT_SYS state
int sys_natoms;
int *sys_types;
double *sys_charges,*sys_coords,*sys_velocities;
double *sys_cell,*sys_cell_displ;
// create_atoms state
int create_atoms_flag;
int create_natoms;
tagint *create_id;
@ -91,29 +101,52 @@ class MDIEngine : public Command {
void mdi_commands();
void mdi_md();
void mdi_optg();
void mdi_sys();
void evaluate();
void receive_cell();
void receive_cell_default();
void receive_cell_sys();
void receive_cell_displ();
void receive_cell_displ_default();
void receive_cell_displ_sys();
void receive_charges();
void receive_charges_sys();
void receive_coords();
void receive_coords_sys();
void receive_natoms();
void send_natoms();
void send_ntypes();
void receive_natoms_default();
void receive_natoms_sys();
void receive_types();
void receive_types_sys();
void receive_velocities();
void receive_velocities_sys();
void receive_double1(int);
void receive_int1(int);
void receive_double3(int, int);
void send_natoms();
void send_ntypes();
void send_double1(int);
void send_int1(int);
void send_double3(int);
void send_labels();
void send_total_energy();
void send_energy();
void send_pe();
void send_ke();
void send_cell();
void receive_cell();
void send_celldispl();
void receive_celldispl();
void send_cell_displ();
void nbytes_command();
void single_command();