Merge pull request #17 from akohlmey/mdi_update
MDI formatting updates and MPI STUBS handling
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -11,11 +11,10 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#ifdef FIX_CLASS
|
||||
|
||||
FixStyle(mdi/engine,FixMDIEngine)
|
||||
|
||||
// clang-format off
|
||||
FixStyle(mdi/engine, FixMDIEngine);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_FIX_MDI_ENGINE_H
|
||||
@ -42,12 +41,12 @@ class FixMDIEngine : public Fix {
|
||||
void min_setup(int);
|
||||
void post_integrate();
|
||||
void post_force(int);
|
||||
void min_pre_force(int); //@COORDS
|
||||
void min_post_force(int); //@FORCES
|
||||
void min_pre_force(int); //@COORDS
|
||||
void min_post_force(int); //@FORCES
|
||||
|
||||
double *add_force; // stores forces added using +FORCE command
|
||||
double potential_energy; // stores potential energy
|
||||
double kinetic_energy; // stores kinetic energy
|
||||
double *add_force; // stores forces added using +FORCE command
|
||||
double potential_energy; // stores potential energy
|
||||
double kinetic_energy; // stores kinetic energy
|
||||
|
||||
// current command
|
||||
|
||||
@ -57,23 +56,23 @@ class FixMDIEngine : public Fix {
|
||||
void exchange_forces();
|
||||
|
||||
private:
|
||||
int lmpunits; // REAL or METAL
|
||||
int lmpunits; // REAL or METAL
|
||||
int master, ierr;
|
||||
int driver_socket;
|
||||
int most_recent_init; // which MDI init command was most recently received?
|
||||
// 0 - none
|
||||
// 1 - MD
|
||||
// 2 - OPTG
|
||||
int most_recent_init; // which MDI init command was most recently received?
|
||||
// 0 - none
|
||||
// 1 - MD
|
||||
// 2 - OPTG
|
||||
bool exit_flag;
|
||||
bool local_exit_flag;
|
||||
char *current_node;
|
||||
char *target_node; // is the code supposed to advance to a particular node?
|
||||
// 0 - none
|
||||
// 1 - @COORDS (before pre-force calculation)
|
||||
// 2 - @PRE-FORCES (before final force calculation)
|
||||
// 3 - @FORCES (before time integration)
|
||||
// -1 - after MD_INIT command
|
||||
// -2 - after MD_INIT command followed by @PRE-FORCES (actually @INIT_OPTG?)
|
||||
char *target_node; // is the code supposed to advance to a particular node?
|
||||
// 0 - none
|
||||
// 1 - @COORDS (before pre-force calculation)
|
||||
// 2 - @PRE-FORCES (before final force calculation)
|
||||
// 3 - @FORCES (before time integration)
|
||||
// -1 - after MD_INIT command
|
||||
// -2 - after MD_INIT command followed by @PRE-FORCES (actually @INIT_OPTG?)
|
||||
|
||||
// command to be executed at the target node
|
||||
|
||||
@ -103,7 +102,7 @@ class FixMDIEngine : public Fix {
|
||||
void receive_celldispl(Error *);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -82,7 +82,11 @@ int MDI_Plugin_init_lammps()
|
||||
if (!found_filename) MPI_Abort(MPI_COMM_WORLD, 1);
|
||||
|
||||
// create and run a LAMMPS instance
|
||||
auto lmp = lammps_open(mdi_argc, mdi_argv, mpi_world_comm, NULL);
|
||||
void *lmp = nullptr;
|
||||
if (lammps_config_has_mpi_support() > 0)
|
||||
lmp = lammps_open(mdi_argc, mdi_argv, mpi_world_comm, nullptr);
|
||||
else
|
||||
lmp = lammps_open_no_mpi(mdi_argc, mdi_argv, nullptr);
|
||||
lammps_file(lmp, filename);
|
||||
lammps_close(lmp);
|
||||
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
#include "update.h"
|
||||
#include "verlet.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <limits>
|
||||
#include <string.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -188,17 +188,15 @@ void MDIEngine::command(int narg, char **arg)
|
||||
// identify the mdi_engine fix
|
||||
|
||||
ifix = modify->find_fix_by_style("mdi/engine");
|
||||
mdi_fix = static_cast<FixMDIEngine*>(modify->fix[ifix]);
|
||||
mdi_fix = static_cast<FixMDIEngine *>(modify->fix[ifix]);
|
||||
|
||||
// check that LAMMPS is setup as a compatible MDI engine
|
||||
|
||||
if (narg > 0) error->all(FLERR,"Illegal mdi/engine command");
|
||||
if (narg > 0) error->all(FLERR, "Illegal mdi/engine command");
|
||||
|
||||
if (atom->tag_enable == 0)
|
||||
error->all(FLERR,"Cannot use mdi/engine without atom IDs");
|
||||
if (atom->tag_enable == 0) error->all(FLERR, "Cannot use mdi/engine without atom IDs");
|
||||
|
||||
if (atom->tag_consecutive() == 0)
|
||||
error->all(FLERR,"mdi/engine requires consecutive atom IDs");
|
||||
if (atom->tag_consecutive() == 0) error->all(FLERR, "mdi/engine requires consecutive atom IDs");
|
||||
|
||||
// endless engine loop, responding to driver commands
|
||||
|
||||
@ -213,21 +211,22 @@ void MDIEngine::command(int narg, char **arg)
|
||||
|
||||
// MDI commands for dynamics or minimization
|
||||
|
||||
if (strcmp(command,"@INIT_MD") == 0 ) {
|
||||
if (strcmp(command, "@INIT_MD") == 0) {
|
||||
command = mdi_md();
|
||||
if (strcmp(command,"EXIT")) break;
|
||||
if (strcmp(command, "EXIT")) break;
|
||||
|
||||
} else if (strcmp(command,"@INIT_OPTG") == 0 ) {
|
||||
} else if (strcmp(command, "@INIT_OPTG") == 0) {
|
||||
command = mdi_optg();
|
||||
if (strcmp(command,"EXIT")) break;
|
||||
if (strcmp(command, "EXIT")) break;
|
||||
|
||||
} else if (strcmp(command,"EXIT") == 0) {
|
||||
} else if (strcmp(command, "EXIT") == 0) {
|
||||
break;
|
||||
|
||||
} else
|
||||
error->all(FLERR,
|
||||
fmt::format("MDI node exited with "
|
||||
"invalid command: {}",command));
|
||||
"invalid command: {}",
|
||||
command));
|
||||
}
|
||||
|
||||
// remove mdi/engine fix that mdi/engine instantiated
|
||||
@ -256,11 +255,10 @@ char *MDIEngine::mdi_md()
|
||||
|
||||
// engine is now at @INIT_MD node
|
||||
|
||||
char *command = NULL;
|
||||
char *command = nullptr;
|
||||
command = mdi_fix->engine_mode("@INIT_MD");
|
||||
|
||||
if (strcmp(command,"@DEFAULT") == 0 || strcmp(command,"EXIT") == 0)
|
||||
return command;
|
||||
if (strcmp(command, "@DEFAULT") == 0 || strcmp(command, "EXIT") == 0) return command;
|
||||
|
||||
// setup the MD simulation
|
||||
|
||||
@ -268,8 +266,7 @@ char *MDIEngine::mdi_md()
|
||||
|
||||
command = mdi_fix->engine_mode("@FORCES");
|
||||
|
||||
if (strcmp(command,"@DEFAULT") == 0 || strcmp(command,"EXIT") == 0)
|
||||
return command;
|
||||
if (strcmp(command, "@DEFAULT") == 0 || strcmp(command, "EXIT") == 0) return command;
|
||||
|
||||
// run MD one step at a time
|
||||
|
||||
@ -289,11 +286,10 @@ char *MDIEngine::mdi_md()
|
||||
|
||||
command = mdi_fix->command;
|
||||
|
||||
if (strcmp(command,"@DEFAULT") == 0 || strcmp(command,"EXIT") == 0)
|
||||
return command;
|
||||
if (strcmp(command, "@DEFAULT") == 0 || strcmp(command, "EXIT") == 0) return command;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -322,11 +318,10 @@ char *MDIEngine::mdi_optg()
|
||||
|
||||
// engine is now at @INIT_OPTG node
|
||||
|
||||
char *command = NULL;
|
||||
char *command = nullptr;
|
||||
command = mdi_fix->engine_mode("@INIT_OPTG");
|
||||
|
||||
if (strcmp(command,"@DEFAULT") == 0 || strcmp(command,"EXIT") == 0)
|
||||
return command;
|
||||
if (strcmp(command, "@DEFAULT") == 0 || strcmp(command, "EXIT") == 0) return command;
|
||||
|
||||
// setup the minimization
|
||||
|
||||
@ -336,8 +331,7 @@ char *MDIEngine::mdi_optg()
|
||||
|
||||
command = mdi_fix->command;
|
||||
|
||||
if (strcmp(command,"@DEFAULT") == 0 || strcmp(command,"EXIT") == 0)
|
||||
return command;
|
||||
if (strcmp(command, "@DEFAULT") == 0 || strcmp(command, "EXIT") == 0) return command;
|
||||
|
||||
// Start a minimization, which is configured to run (essentially)
|
||||
// infinite steps. When the driver sends the EXIT command,
|
||||
@ -350,11 +344,11 @@ char *MDIEngine::mdi_optg()
|
||||
|
||||
command = mdi_fix->command;
|
||||
|
||||
if (strcmp(command,"@DEFAULT") == 0 || strcmp(command,"EXIT") == 0)
|
||||
return command;
|
||||
if (strcmp(command, "@DEFAULT") == 0 || strcmp(command, "EXIT") == 0) return command;
|
||||
|
||||
error->all(FLERR,
|
||||
fmt::format("MDI reached end of OPTG simulation "
|
||||
"with invalid command: {}",command));
|
||||
return NULL;
|
||||
"with invalid command: {}",
|
||||
command));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -12,9 +12,9 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef COMMAND_CLASS
|
||||
|
||||
CommandStyle(mdi/engine,MDIEngine)
|
||||
|
||||
// clang-format off
|
||||
CommandStyle(mdi/engine, MDIEngine);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_MDI_ENGINE_H
|
||||
@ -30,14 +30,14 @@ class MDIEngine : public Command {
|
||||
virtual ~MDIEngine() {}
|
||||
void command(int, char **);
|
||||
|
||||
private:
|
||||
private:
|
||||
class FixMDIEngine *mdi_fix;
|
||||
|
||||
char *mdi_md();
|
||||
char *mdi_optg();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user