change what is required/optional for mdi plugin command

This commit is contained in:
Steve Plimpton
2022-07-20 09:55:19 -06:00
parent 9061be98c2
commit d6e8e044df
3 changed files with 28 additions and 23 deletions

View File

@ -125,13 +125,14 @@ LAMMPS atom type corresponds to. This is specified by the atomic
number of the element, e.g. 13 for Al. An atomic number must be
specified for each of the ntypes LAMMPS atom types. Ntypes is
typically specified via the create_box command or in the data file
read by the read_data command. If this keyword is not specified, then
this fix will send the LAMMPS atom type for each atom to the MDI
engine. If both the LAMMPS driver and the MDI engine are initialized
so that atom type values are consistent in both codes, then the
*elements* keyword is not needed. Otherwise the keyword can be used
to insure the two codes are consistent in their definition of atomic
species.
read by the read_data command.
If this keyword is specified, then this fix will send the MDI
">ELEMENTS" command to the engine, to insure the two codes are
consistent in their definition of atomic species. If this keyword is
not specified, then this fix will send the MDI >TYPES command to the
engine. This is fine if both the LAMMPS driver and the MDI engine are
initialized so that the atom type values are consistent in both codes.
----------

View File

@ -14,7 +14,7 @@ Syntax
.. parsed-literal::
*engine* args = zero or more keyword arg pairs
*engine* args = zero or more keyword/args pairs
keywords = *elements*
*elements* args = N_1 N_2 ... N_ntypes
N_1,N_2,...N_ntypes = atomic number for each of ntypes LAMMPS atom types
@ -24,7 +24,7 @@ Syntax
keywords = *mdi* or *infile* or *extra* or *command*
*mdi* value = args passed to MDI for driver to operate with plugins (required)
*infile* value = filename the engine will read at start-up (optional)
*extra* value = aditional command-line args to pass to engine library when loaded
*extra* value = aditional command-line args to pass to engine library when loaded (optional)
*command* value = a LAMMPS input script command to execute (required)
*connect* args = none
*exit* args = none
@ -289,11 +289,11 @@ are required. The -name setting can be anything you choose. MDI
drivers and engines can query their names to verify they are values
they expect.
The *infile* keyword is also required. It is the name of an input
script which the engine will open and process. MDI will pass it as a
The *infile* keyword is optional. It sets the name of an input script
which the engine will open and process. MDI will pass it as a
command-line argument to the library when it is launched. The file
typically contains settings that an MD or QM code will use for its
subsequent calculations.
calculations.
The *extra* keyword is optional. It contains additional command-line
arguments which MDI will pass to the library when it is launched.
@ -309,12 +309,12 @@ could specify a filename with multiple LAMMPS commands.
.. note::
When the single *command* is complete, LAMMPS will send an MDI
EXIT command to the plugin engine and the plugin will be removed.
The "mdi plugin" command will then exit and the next command
(if any) in the LAMMPS input script will be processed. A subsequent
"mdi plugin" command could then load the same library plugin or
a different one if desired.
When the *command* is complete, LAMMPS will send an MDI EXIT
command to the plugin engine and the plugin will be removed. The
"mdi plugin" command will then exit and the next command (if any)
in the LAMMPS input script will be processed. A subsequent "mdi
plugin" command could then load the same or a different MDI
plugin if desired.
----------

View File

@ -74,18 +74,22 @@ MDIPlugin::MDIPlugin(LAMMPS *_lmp, int narg, char **arg) : Pointers(_lmp)
// error checks
if (!mdi_arg || !infile_arg || !lammps_command)
error->all(FLERR, "MDI plugin must specify mdi, infile, command keywords");
if (!mdi_arg || !lammps_command)
error->all(FLERR, "MDI plugin must specify mdi and command keywords");
// build full plugin_args string for args to plugin library
int n = strlen(mdi_arg) + strlen(infile_arg) + strlen(extra_arg) + 16;
int n = strlen(mdi_arg) + 16;
if (infile_arg) n += strlen(infile_arg);
if (extra_arg) n += strlen(extra_arg);
auto plugin_args = new char[n];
plugin_args[0] = 0;
strcat(plugin_args, "-mdi \"");
strcat(plugin_args, mdi_arg);
strcat(plugin_args, "\" -in ");
strcat(plugin_args, infile_arg);
if (infile_arg) {
strcat(plugin_args, "\" -in ");
strcat(plugin_args, infile_arg);
}
if (extra_arg) {
strcat(plugin_args, " ");
strcat(plugin_args, extra_arg);