|
|
|
|
@ -54,7 +54,7 @@ enum { DEFAULT, MD, OPT }; // top-level MDI engine modes
|
|
|
|
|
|
|
|
|
|
enum { TYPE, CHARGE, MASS, COORD, VELOCITY, FORCE, ADDFORCE };
|
|
|
|
|
|
|
|
|
|
#define MAXELEMENT 103 // used elsewhere in MDI package
|
|
|
|
|
#define MAXELEMENT 103 // used elsewhere in MDI package
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
|
trigger LAMMPS to start acting as an MDI engine
|
|
|
|
|
@ -65,7 +65,7 @@ enum { TYPE, CHARGE, MASS, COORD, VELOCITY, FORCE, ADDFORCE };
|
|
|
|
|
when EXIT command is received, mdi engine command exits
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char ** arg) : Pointers(_lmp)
|
|
|
|
|
MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char **arg) : Pointers(_lmp)
|
|
|
|
|
{
|
|
|
|
|
// check requirements for LAMMPS to work with MDI as an engine
|
|
|
|
|
|
|
|
|
|
@ -80,18 +80,19 @@ MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char ** arg) : Pointers(_lmp)
|
|
|
|
|
|
|
|
|
|
int iarg = 0;
|
|
|
|
|
while (iarg < narg) {
|
|
|
|
|
if (strcmp(arg[iarg],"elements") == 0) {
|
|
|
|
|
if (strcmp(arg[iarg], "elements") == 0) {
|
|
|
|
|
int ntypes = atom->ntypes;
|
|
|
|
|
delete [] elements;
|
|
|
|
|
elements = new int[ntypes+1];
|
|
|
|
|
if (iarg+ntypes+1 > narg) error->all(FLERR,"Illegal mdi engine command");
|
|
|
|
|
delete[] elements;
|
|
|
|
|
elements = new int[ntypes + 1];
|
|
|
|
|
if (iarg + ntypes + 1 > narg) error->all(FLERR, "Illegal mdi engine command");
|
|
|
|
|
for (int i = 1; i <= ntypes; i++) {
|
|
|
|
|
elements[i] = utils::inumeric(FLERR,arg[iarg+i],false,lmp);
|
|
|
|
|
elements[i] = utils::inumeric(FLERR, arg[iarg + i], false, lmp);
|
|
|
|
|
if (elements[i] < 0 || elements[i] > MAXELEMENT)
|
|
|
|
|
error->all(FLERR,"Illegal mdi engine command");
|
|
|
|
|
error->all(FLERR, "Illegal mdi engine command");
|
|
|
|
|
}
|
|
|
|
|
iarg += ntypes+1;
|
|
|
|
|
} else error->all(FLERR,"Illegal mdi engine command");
|
|
|
|
|
iarg += ntypes + 1;
|
|
|
|
|
} else
|
|
|
|
|
error->all(FLERR, "Illegal mdi engine command");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// error check an MDI element does not map to multiple atom types
|
|
|
|
|
@ -99,10 +100,10 @@ MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char ** arg) : Pointers(_lmp)
|
|
|
|
|
if (elements) {
|
|
|
|
|
int ntypes = atom->ntypes;
|
|
|
|
|
for (int i = 1; i < ntypes; i++)
|
|
|
|
|
for (int j = i+1; j <= ntypes; j++) {
|
|
|
|
|
for (int j = i + 1; j <= ntypes; j++) {
|
|
|
|
|
if (elements[i] == 0 || elements[j] == 0) continue;
|
|
|
|
|
if (elements[i] == elements[j])
|
|
|
|
|
error->all(FLERR,"MDI engine element cannot map to multiple types");
|
|
|
|
|
error->all(FLERR, "MDI engine element cannot map to multiple types");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -167,7 +168,7 @@ MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char ** arg) : Pointers(_lmp)
|
|
|
|
|
ibuf1 = ibuf1all = nullptr;
|
|
|
|
|
|
|
|
|
|
maxatom = 0;
|
|
|
|
|
sys_natoms = static_cast<int> (atom->natoms);
|
|
|
|
|
sys_natoms = static_cast<int>(atom->natoms);
|
|
|
|
|
reallocate();
|
|
|
|
|
|
|
|
|
|
nsteps = 0;
|
|
|
|
|
@ -297,8 +298,7 @@ void MDIEngine::engine_node(const char *node)
|
|
|
|
|
this is a static method in mdi_engine.h
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
int MDIEngine::execute_command_plugin_wrapper(const char *command,
|
|
|
|
|
MDI_Comm comm, void *class_obj)
|
|
|
|
|
int MDIEngine::execute_command_plugin_wrapper(const char *command, MDI_Comm comm, void *class_obj)
|
|
|
|
|
{
|
|
|
|
|
auto mdi_engine = (MDIEngine *) class_obj;
|
|
|
|
|
return mdi_engine->execute_command(command, comm);
|
|
|
|
|
@ -346,8 +346,7 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
|
|
|
|
|
receive_coords();
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(command, ">ELEMENTS") == 0) {
|
|
|
|
|
if (!elements)
|
|
|
|
|
error->all(FLERR,"MDI engine command did not define element list");
|
|
|
|
|
if (!elements) error->all(FLERR, "MDI engine command did not define element list");
|
|
|
|
|
receive_elements();
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(command, ">FORCES") == 0) {
|
|
|
|
|
@ -374,7 +373,7 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
|
|
|
|
|
else
|
|
|
|
|
receive_double3(VELOCITY);
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------
|
|
|
|
|
// -----------------------------------------------
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(command, "<@") == 0) {
|
|
|
|
|
ierr = MDI_Send(node_engine, MDI_NAME_LENGTH, MDI_CHAR, mdicomm);
|
|
|
|
|
@ -423,9 +422,9 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
|
|
|
|
|
} else if (strcmp(command, "<VELOCITIES") == 0) {
|
|
|
|
|
send_double3(VELOCITY);
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------
|
|
|
|
|
// -----------------------------------------------
|
|
|
|
|
|
|
|
|
|
// MDI action commands at @DEFAULT node
|
|
|
|
|
// MDI action commands at @DEFAULT node
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(command, "MD") == 0) {
|
|
|
|
|
md();
|
|
|
|
|
@ -433,9 +432,9 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
|
|
|
|
|
} else if (strcmp(command, "OPTG") == 0) {
|
|
|
|
|
optg();
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------
|
|
|
|
|
// -----------------------------------------------
|
|
|
|
|
|
|
|
|
|
// MDI node commands
|
|
|
|
|
// MDI node commands
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(command, "@INIT_MD") == 0) {
|
|
|
|
|
if (mode != DEFAULT) error->all(FLERR, "MDI: MDI engine is already performing a simulation");
|
|
|
|
|
@ -470,14 +469,14 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
|
|
|
|
|
strncpy(node_driver, command, MDI_COMMAND_LENGTH);
|
|
|
|
|
node_match = false;
|
|
|
|
|
|
|
|
|
|
// exit command
|
|
|
|
|
// exit command
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(command, "EXIT") == 0) {
|
|
|
|
|
exit_command = true;
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
// custom LAMMPS commands
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
// custom LAMMPS commands
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(command, "NBYTES") == 0) {
|
|
|
|
|
nbytes_command();
|
|
|
|
|
@ -490,9 +489,9 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
|
|
|
|
|
} else if (strcmp(command, "<KE") == 0) {
|
|
|
|
|
send_ke();
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
// unknown command
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
// unknown command
|
|
|
|
|
// -------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
error->all(FLERR, "MDI: Unknown command {} received from driver", command);
|
|
|
|
|
@ -1010,9 +1009,9 @@ void MDIEngine::create_system()
|
|
|
|
|
// create list of 1 to sys_natoms IDs
|
|
|
|
|
// optionally set charges if specified by ">CHARGES"
|
|
|
|
|
|
|
|
|
|
tagint* sys_ids;
|
|
|
|
|
tagint *sys_ids;
|
|
|
|
|
memory->create(sys_ids, sys_natoms, "mdi:sys_ids");
|
|
|
|
|
for (int i = 0; i < sys_natoms; i++) sys_ids[i] = i+1;
|
|
|
|
|
for (int i = 0; i < sys_natoms; i++) sys_ids[i] = i + 1;
|
|
|
|
|
|
|
|
|
|
if (flag_velocities)
|
|
|
|
|
lammps_create_atoms(lmp, sys_natoms, sys_ids, sys_types, sys_coords, sys_velocities, nullptr,
|
|
|
|
|
@ -1163,13 +1162,12 @@ void MDIEngine::receive_cell()
|
|
|
|
|
// 3,7,6 = xy, yz, xz tilt factors
|
|
|
|
|
|
|
|
|
|
if (sys_cell[1] != 0.0 || sys_cell[2] != 0.0 || sys_cell[5] != 0.0)
|
|
|
|
|
error->all(FLERR,
|
|
|
|
|
"MDI: Received cell edges are not an upper triangular matrix");
|
|
|
|
|
error->all(FLERR, "MDI: Received cell edges are not an upper triangular matrix");
|
|
|
|
|
|
|
|
|
|
if (sys_cell[3] != 0.0 || sys_cell[7] != 0.0 || sys_cell[6] != 0.0)
|
|
|
|
|
if (!domain->triclinic)
|
|
|
|
|
error->all(FLERR,
|
|
|
|
|
"MDI: Received cell edges are for a triclinic box, "
|
|
|
|
|
error->all(FLERR,
|
|
|
|
|
"MDI: Received cell edges are for a triclinic box, "
|
|
|
|
|
"but LAMMPS is using an orthogonal box");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1247,8 +1245,7 @@ void MDIEngine::receive_elements()
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (itype > ntypes)
|
|
|
|
|
error->all(FLERR,"MDI element not found in element list");
|
|
|
|
|
if (itype > ntypes) error->all(FLERR, "MDI element not found in element list");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|