more doc page edits for enhanced fix mdi/qm command
This commit is contained in:
@ -103,7 +103,7 @@ OPT.
|
||||
* :doc:`lb/viscous <fix_lb_viscous>`
|
||||
* :doc:`lineforce <fix_lineforce>`
|
||||
* :doc:`manifoldforce <fix_manifoldforce>`
|
||||
* :doc:`mdi/aimd <fix_mdi_aimd>`
|
||||
* :doc:`mdi/qm <fix_mdi_qm>`
|
||||
* :doc:`meso/move <fix_meso_move>`
|
||||
* :doc:`mol/swap <fix_mol_swap>`
|
||||
* :doc:`momentum (k) <fix_momentum>`
|
||||
|
||||
@ -63,12 +63,18 @@ The package also provides a :doc:`mdi plugin <mdi>` command which
|
||||
enables LAMMPS to operate as an MDI driver and load an MDI engine as a
|
||||
plugin library.
|
||||
|
||||
The package also has a `fix mdi/aimd <fix_mdi_aimd>` command in which
|
||||
LAMMPS operates as an MDI driver to perform *ab initio* MD simulations
|
||||
in conjunction with a quantum mechanics code. Its post_force() method
|
||||
illustrates how a driver issues MDI commands to another code. This
|
||||
command can be used to couple to an MDI engine which is either a
|
||||
stand-alone code or a plugin library.
|
||||
The package also has a `fix mdi/qm <fix_mdi_qm>` command in which
|
||||
LAMMPS operates as an MDI driver in conjunction with a quantum
|
||||
mechanics code as an MDI engine. The post_force() method of the
|
||||
fix_mdi_qm.cpp file shows how a driver issues MDI commands to another
|
||||
code. This command can be used to couple to an MDI engine which is
|
||||
either a stand-alone code or a plugin library.
|
||||
|
||||
As explained on the `fix mdi/qm <fix_mdi_qm>` command doc page, it can
|
||||
be used to perform *ab initio* MD simulations or energy minimizations,
|
||||
or to evalute the quantum energy and forces for a series of
|
||||
independent systems. The examples/mdi directory has example input
|
||||
scripts for all of these use cases.
|
||||
|
||||
----------
|
||||
|
||||
|
||||
@ -246,7 +246,7 @@ accelerated styles exist.
|
||||
* :doc:`lb/viscous <fix_lb_viscous>` -
|
||||
* :doc:`lineforce <fix_lineforce>` - constrain atoms to move in a line
|
||||
* :doc:`manifoldforce <fix_manifoldforce>` - restrain atoms to a manifold during minimization
|
||||
* :doc:`mdi/aimd <fix_mdi_aimd>` - LAMMPS operates as driver for ab initio MD (AIMD) via the MolSSI Driver Interface (MDI)
|
||||
* :doc:`mdi/qm <fix_mdi_qm>` - LAMMPS operates as driver for a quantum code via the MolSSI Driver Interface (MDI)
|
||||
* :doc:`meso/move <fix_meso_move>` - move mesoscopic SPH/SDPD particles in a prescribed fashion
|
||||
* :doc:`mol/swap <fix_mol_swap>` - Monte Carlo atom type swapping with a molecule
|
||||
* :doc:`momentum <fix_momentum>` - zero the linear and/or angular momentum of a group of atoms
|
||||
|
||||
@ -116,13 +116,6 @@ potential energy of the system as part of :doc:`thermodynamic output
|
||||
<thermo_style>`. The default setting for this fix is :doc:`fix_modify
|
||||
energy yes <fix_modify>`.
|
||||
|
||||
The :doc:`fix_modify <fix_modify>` *virial* option is supported by
|
||||
this fix to add the contribution compute by LATTE to the global
|
||||
pressure of the system via the :doc:`compute pressure
|
||||
<compute_pressure>` command. This can be accessed by
|
||||
:doc:`thermodynamic output <thermo_style>`. The default setting for
|
||||
this fix is :doc:`fix_modify virial yes <fix_modify>`.
|
||||
|
||||
The :doc:`fix_modify <fix_modify>` *virial* option is supported by
|
||||
this fix to add the contribution computed by LATTE to the global
|
||||
pressure of the system as part of :doc:`thermodynamic output
|
||||
@ -137,7 +130,7 @@ energy discussed above. The scalar value calculated by this fix is
|
||||
No parameter of this fix can be used with the *start/stop* keywords of
|
||||
the :doc:`run <run>` command.
|
||||
|
||||
The DFTB forces computed by LATTE via this fix are imposed during an
|
||||
The DFTB forces computed by LATTE via this fix are used during an
|
||||
energy minimization, invoked by the :doc:`minimize <minimize>`
|
||||
command.
|
||||
|
||||
|
||||
@ -1,138 +0,0 @@
|
||||
.. index:: fix mdi/qm
|
||||
|
||||
fix mdi/qm command
|
||||
======================
|
||||
|
||||
Syntax
|
||||
""""""
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
fix ID group-ID mdi/qm keyword
|
||||
|
||||
* ID, group-ID are documented in :doc:`fix <fix>` command
|
||||
* mdi/qm = style name of this fix command
|
||||
* zero or more keyword/value pairs may be appended
|
||||
* keyword = *plugin* or *every* or *add*
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
*plugin* args = none
|
||||
*every* args = Nevery
|
||||
Nevery = request values from server code once every Nevery steps
|
||||
*add* args = *yes* or *no*
|
||||
yes = add returned value from server code to LAMMPS quantities
|
||||
no = do not add returned values to LAMMPS quantities
|
||||
|
||||
Examples
|
||||
""""""""
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
fix 1 all mdi/aimd
|
||||
fix 1 all mdi/aimd plugin
|
||||
|
||||
Description
|
||||
"""""""""""
|
||||
|
||||
This command enables LAMMPS to act as a client with another server
|
||||
code that will compute the total energy, per-atom forces, and total
|
||||
virial for atom conformations and simulation box size/shapes that
|
||||
LAMMPS sends it.
|
||||
|
||||
Typically the server code will be a quantum code, hence the name of
|
||||
the fix. However this is not required, the server code could be
|
||||
another classical molecular dynamics code or LAMMPS itself. The
|
||||
server code must support use of the `MDI Library
|
||||
<https://molssi-mdi.github.io/MDI_Library/html/index.html>`_ as
|
||||
explained below.
|
||||
|
||||
Example use cases for this fix are the following (discussed further
|
||||
below):
|
||||
|
||||
* perform an ab intitio MD (AIMD) simulation with quantum forces
|
||||
* perform an energy minimziation with quantum forces
|
||||
* perform a nudged elatic band (NEB) calculation with quantum forces
|
||||
* requests a QM calculation for a series of independent systems which LAMMPS reads or generates
|
||||
|
||||
The code coupling performed by this command is done via the `MDI
|
||||
Library <https://molssi-mdi.github.io/MDI_Library/html/index.html>`_.
|
||||
LAMMPS runs as an MDI driver (client), and sends MDI commands to an
|
||||
external MDI engine code (server), e.g. a quantum code which has
|
||||
support for MDI. See the :doc:`Howto mdi <Howto_mdi>` page for more
|
||||
information about how LAMMPS can operate as either an MDI driver or
|
||||
engine.
|
||||
|
||||
The examples/mdi directory contains input scripts using this fix, with
|
||||
two instances of LAMMPS acting as both a driver and an engine
|
||||
(surrogate for a QM code). The examples/mdi/README file explains how
|
||||
to launch two driver and engine codes so that they communicate using
|
||||
the MDI library via either MPI or sockets. Any QM code that supports
|
||||
MDI could be used in place of LAMMPS acting as a QM surrogate. See
|
||||
the :doc:`Howto mdi <Howto_mdi>` page for a current list (March 2022)
|
||||
of such QM codes.
|
||||
|
||||
Engine codes can support MDI in either or both of two ways. It can
|
||||
support being used as a stand-alone code, launched at the same time as
|
||||
LAMMPS. Or it can support being used as a plugin library, which
|
||||
LAMMPS loads. See the :doc:`mdi plugin <mdi>` command for how to
|
||||
trigger LAMMPS to load the plugin library. The examples/mdi/README
|
||||
file explains both use cases: launching both the driver and engine as
|
||||
stand-alone codes or having the driver code load an engine as a plugin
|
||||
library.
|
||||
|
||||
----------
|
||||
|
||||
|
||||
|
||||
To use this fix with a plugin engine, you must specify the
|
||||
*plugin* keyword as the last argument, as illustrated above.
|
||||
|
||||
|
||||
----------
|
||||
|
||||
----------
|
||||
|
||||
This fix performs the timestepping portion of anAIMD simulation.
|
||||
Both LAMMPS and the engine code (QM or LAMMPS) should define the same
|
||||
system (simulation box, atoms and their types) in their respective
|
||||
input scripts. LAMMPS then begins its timestepping.
|
||||
|
||||
At the point in each timestep when LAMMPS needs the force on each
|
||||
atom, it communicates with the engine code. It sends the current
|
||||
simulation box size and shape (if they change dynamically, e.g. during
|
||||
an NPT simulation), and the current atom coordinates. The engine code
|
||||
computes quantum forces on each atom and returns them to LAMMPS. If
|
||||
LAMMPS also needs the system energy and/or virial, it requests those
|
||||
values from the engine code as well.
|
||||
|
||||
Restrictions
|
||||
""""""""""""
|
||||
|
||||
This command is part of the MDI package. It is only enabled if
|
||||
LAMMPS was built with that package. See the :doc:`Build package
|
||||
<Build_package>` page for more info.
|
||||
|
||||
Stored values by fix: energy, per-atoms forces, virial.
|
||||
|
||||
|
||||
|
||||
To use LAMMPS as an MDI driver in conjunction with other MDI-enabled
|
||||
atomistic codes, the :doc:`units <units>` command should be used to
|
||||
specify *real* or *metal* units. This will ensure the correct unit
|
||||
conversions between LAMMPS and MDI units. The other code will also
|
||||
perform similar unit conversions into its preferred units.
|
||||
|
||||
LAMMPS can also be used as an MDI driver in other unit choices it
|
||||
supports, e.g. *lj*, but then no unit conversion is performed.
|
||||
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
:doc:`mdi engine <mdi>`
|
||||
|
||||
Default
|
||||
"""""""
|
||||
|
||||
The default for the optional keywords is add = yes, every = 1.
|
||||
|
||||
232
doc/src/fix_mdi_qm.rst
Normal file
232
doc/src/fix_mdi_qm.rst
Normal file
@ -0,0 +1,232 @@
|
||||
.. index:: fix mdi/qm
|
||||
|
||||
fix mdi/qm command
|
||||
======================
|
||||
|
||||
Syntax
|
||||
""""""
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
fix ID group-ID mdi/qm keyword
|
||||
|
||||
* ID, group-ID are documented in :doc:`fix <fix>` command
|
||||
* mdi/qm = style name of this fix command
|
||||
* zero or more keyword/value pairs may be appended
|
||||
* keyword = *add* or *every*
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
*add* args = *yes* or *no*
|
||||
yes = add returned value from server code to LAMMPS quantities
|
||||
no = do not add returned values to LAMMPS quantities
|
||||
*every* args = Nevery
|
||||
Nevery = request values from server code once every Nevery steps
|
||||
|
||||
Examples
|
||||
""""""""
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
fix 1 all mdi/qm
|
||||
fix 1 all mdi/qm add no every 100
|
||||
|
||||
Description
|
||||
"""""""""""
|
||||
|
||||
This command enables LAMMPS to act as a client with another server
|
||||
code that will compute the total energy, per-atom forces, and total
|
||||
virial for atom conformations and simulation box size/shapes that
|
||||
LAMMPS sends it.
|
||||
|
||||
Typically the server code will be a quantum mechanics (QM) code, hence
|
||||
the name of the fix. However this is not required, the server code
|
||||
could be another classical molecular dynamics code or LAMMPS itself.
|
||||
The server code must support use of the `MDI Library
|
||||
<https://molssi-mdi.github.io/MDI_Library/html/index.html>`_ as
|
||||
explained below.
|
||||
|
||||
These are example use cases for this fix, discussed further below:
|
||||
|
||||
* perform an ab intitio MD (AIMD) simulation with quantum forces
|
||||
* perform an energy minimziation with quantum forces
|
||||
* perform a nudged elatic band (NEB) calculation with quantum forces
|
||||
* perform a QM calculation for a series of independent systems which LAMMPS reads or generates
|
||||
|
||||
The code coupling performed by this command is done via the `MDI
|
||||
Library <https://molssi-mdi.github.io/MDI_Library/html/index.html>`_.
|
||||
LAMMPS runs as an MDI driver (client), and sends MDI commands to an
|
||||
external MDI engine code (server), e.g. a QM code which has support
|
||||
for MDI. See the :doc:`Howto mdi <Howto_mdi>` page for more
|
||||
information about how LAMMPS can operate as either an MDI driver or
|
||||
engine.
|
||||
|
||||
The examples/mdi directory contains input scripts using this fix in
|
||||
the various use cases listed above. In each case, two instances of
|
||||
LAMMPS are used, once as an MDI driver, once as an MDI engine
|
||||
(surrogate for a QM code). The examples/mdi/README file explains how
|
||||
to launch two codes so that they communicate via the MDI library using
|
||||
either MPI or sockets. Any QM code that supports MDI could be used in
|
||||
place of LAMMPS acting as a QM surrogate. See the :doc:`Howto mdi
|
||||
<Howto_mdi>` page for a current list (March 2022) of such QM codes.
|
||||
|
||||
Note that an engine code can support MDI in either or both of two
|
||||
modes. It can be used as a stand-alone code, launched at the same
|
||||
time as LAMMPS. Or it can be used as a plugin library, which LAMMPS
|
||||
loads. See the :doc:`mdi plugin <mdi>` command for how to trigger
|
||||
LAMMPS to load a plugin library. The examples/mdi/README file
|
||||
explains how to launch the two codes in either mode.
|
||||
|
||||
----------
|
||||
|
||||
The *add* keyword setting of *yes* or *no* determines whether the
|
||||
energy and forces returned by the QM code will be added to the LAMMPS
|
||||
internal energy and forces or not. If the setting is *no* then the
|
||||
default :doc:`fix_modify energy <fix_modify>` and :doc:`fix_modify
|
||||
virial <fix_modify>` settings are also set to *no* and your input
|
||||
scripts should not set them to yes. See more details on these
|
||||
fix_modify settings below.
|
||||
|
||||
Whatever the setting for the *add* keyword, the QM energy, forces, and
|
||||
virial will be stored by the fix, so they can be accessed by other
|
||||
commands. See details below.
|
||||
|
||||
The *every* keyword determines how often the QM code will be invoked
|
||||
during a dynamics run with the current LAMMPS simulation box and
|
||||
configuration of atoms. The QM code will be called once every
|
||||
*Nevery* timesteps.
|
||||
|
||||
----------
|
||||
|
||||
3 example use cases:
|
||||
|
||||
(1) To run an ab initio MD (AIMD) dynamics simulation, or an energy
|
||||
minimization with QM forces, or a multi-replica NEB calculation, use
|
||||
*add yes* and *every 1* (the defaults). This is so that every time
|
||||
LAMMPS needs energy and forces, the QM code will be invoked.
|
||||
|
||||
Both LAMMPS and the QM code should define the same system (simulation
|
||||
box, atoms and their types) in their respective input scripts. Note
|
||||
that on this scenario, it may not be necessary for LAMMPS to define a
|
||||
pair style or use a neighbor list.
|
||||
|
||||
LAMMPS will then perform the timestepping for the simulation. At the
|
||||
point in each timestep when LAMMPS needs the force on each atom, it
|
||||
communicates with the engine code. It sends the current simulation
|
||||
box size and shape (if they change dynamically, e.g. during an NPT
|
||||
simulation), and the current atom coordinates. The engine code
|
||||
computes quantum forces on each atom and returns them to LAMMPS. If
|
||||
LAMMPS also needs the system energy and/or virial, it requests those
|
||||
values from the engine code as well.
|
||||
|
||||
(2) To run dynamics with a LAMMPS interatomic potential, and evaluate
|
||||
the QM energy and forces once every 1000 steps, use *add no* and
|
||||
*every 1000*. This could be useful for using an MD run to generate
|
||||
randomized configurations which then generate QM data for training a
|
||||
machine learning potential. A :doc:`dump custom <dump>` command could
|
||||
be invoked every 1000 steps to dump the atom coordinates and QM forces
|
||||
to a file. Likewise the QM energy could be output with the
|
||||
:doc:`thermo_style custom <thermo_style>` command.
|
||||
|
||||
(3) To do a QM evaulation of energy and forces for a series of *N*
|
||||
independent systems (simulation box and atoms), use *add no* and
|
||||
*every 1*. Write a LAMMPS input script which loops over the *N*
|
||||
systems. See the :doc:`Howto multiple <Howto_multiple>` doc page for
|
||||
details on looping and removing old systems. The series of systems
|
||||
could be initialized by reading them from data files with
|
||||
:doc:`read_data <read_data>` commands. Or, for example, by using the
|
||||
:doc:`lattice <lattice>` , :doc:`create_atoms <create_atoms>`,
|
||||
:doc:`delete_atoms <deletea_atoms>`, and/or :doc:`displace_atoms
|
||||
random <displace_atoms>` commands to generate a series of different
|
||||
systems. At the end of the loop perform :doc:`run 0 <run>`
|
||||
and :doc:`write_dump <write_dump>` commands to invoke the QM code
|
||||
and output the QM energy and forces. As in (2) this be useful
|
||||
to generate QM data for training a machine learning potential.
|
||||
|
||||
----------
|
||||
|
||||
Restart, fix_modify, output, run start/stop, minimize info
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
No information about this fix is written to :doc:`binary restart files
|
||||
<restart>`.
|
||||
|
||||
The :doc:`fix_modify <fix_modify>` *energy* option is supported by
|
||||
this fix to add the potential energy computed by the QM code to the
|
||||
global potential energy of the system as part of :doc:`thermodynamic
|
||||
output <thermo_style>`. The default setting for this fix is
|
||||
:doc:`fix_modify energy yes <fix_modify>`, unless the *add* keyword is
|
||||
set to *no*, in which case the default setting is *no*.
|
||||
|
||||
The :doc:`fix_modify <fix_modify>` *virial* option is supported by
|
||||
this fix to add the contribution computed by the QM code to the global
|
||||
pressure of the system as part of :doc:`thermodynamic output
|
||||
<thermo_style>`. The default setting for this fix is :doc:`fix_modify
|
||||
virial yes <fix_modify>`, unless the *add* keyword is set to *no*, in
|
||||
which case the default setting is *no*.
|
||||
|
||||
This fix computes a global scalar which can be accessed by various
|
||||
:doc:`output commands <Howto_output>`. The scalar is the energy
|
||||
returned by the QM code. The scalar value calculated by this fix is
|
||||
"extensive".
|
||||
|
||||
This fix also computes a global vector with of length 6 which contains
|
||||
the symmetric virial tensor values returned by the QM code. It can
|
||||
likewise be accessed by various :doc:`output commands <Howto_output>`.
|
||||
|
||||
The ordering of values in the symmetric virial tensor is as follows:
|
||||
vxx, vyy, vzz, vxy, vxz, vyz. The values will be in pressure
|
||||
:doc:`units <units>`.
|
||||
|
||||
This fix also computes a peratom array with 3 columns which contains
|
||||
the peratom forces returned by the QM code. It can likewise be
|
||||
accessed by various :doc:`output commands <Howto_output>`.
|
||||
|
||||
No parameter of this fix can be used with the *start/stop* keywords of
|
||||
the :doc:`run <run>` command.
|
||||
|
||||
Assuming the *add* keyword is set to *yes* (the default), the forces
|
||||
computed by the QM code are used during an energy minimization,
|
||||
invoked by the :doc:`minimize <minimize>` command.
|
||||
|
||||
.. note::
|
||||
|
||||
If you want the potential energy associated with the QM forces to
|
||||
be included in the total potential energy of the system (the
|
||||
quantity being minimized), you MUST not disable the
|
||||
:doc:`fix_modify <fix_modify>` *energy* option for this fix, which
|
||||
means the *add* keyword should also be set to *yes* (the default).
|
||||
|
||||
|
||||
Restrictions
|
||||
""""""""""""
|
||||
|
||||
This command is part of the MDI package. It is only enabled if
|
||||
LAMMPS was built with that package. See the :doc:`Build package
|
||||
<Build_package>` page for more info.
|
||||
|
||||
The QM code does not currently compute and return per-atom energy or
|
||||
per-atom virial contributions. So they will not show up as part of
|
||||
the calculations performed by the :doc:`compute pe/atom
|
||||
<compute_pe_atom>` or :doc:`compute stress/atom <compute_stress_atom>`
|
||||
commands.
|
||||
|
||||
To use LAMMPS as an MDI driver in conjunction with other MDI-enabled
|
||||
codes (MD or QM codes), the :doc:`units <units>` command should be
|
||||
used to specify *real* or *metal* units. This will ensure the correct
|
||||
unit conversions between LAMMPS and MDI units. The other code will
|
||||
also perform similar unit conversions into its preferred units.
|
||||
|
||||
LAMMPS can also be used as an MDI driver in other unit choices it
|
||||
supports, e.g. *lj*, but then no unit conversion is performed.
|
||||
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
:doc:`mdi plugin <mdi>`, :doc:`mdi engine <mdi>`
|
||||
|
||||
Default
|
||||
"""""""
|
||||
|
||||
The default for the optional keywords is add = yes, every = 1.
|
||||
|
||||
@ -270,7 +270,7 @@ The *command* keyword is required. It specifies a LAMMPS input script
|
||||
command (as a single argument in quotes if it is multiple words).
|
||||
Once the plugin library is launched, LAMMPS will execute this command.
|
||||
Other previously-defined commands in the input script, such as the
|
||||
:doc:`fix mdi/aimd <fix_mdi_aimd>` command, should perform MDI
|
||||
:doc:`fix mdi/qm <fix_mdi_qm>` command, should perform MDI
|
||||
communication with the engine, while the specified *command* executes.
|
||||
Note that if *command* is an :doc:`include <include>` command, then it
|
||||
could specify a filename with multiple LAMMPS commands.
|
||||
@ -304,7 +304,7 @@ supports, e.g. *lj*, but then no unit conversion is performed.
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
:doc:`fix mdi/aimd <fix_mdi_aimd>`
|
||||
:doc:`fix mdi/qm <fix_mdi_qm>`
|
||||
|
||||
Default
|
||||
"""""""
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_mdi_aimd.h"
|
||||
#include "fix_mdi_qm.h"
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "domain.h"
|
||||
@ -27,10 +27,8 @@ enum { NATIVE, REAL, METAL }; // LAMMPS units which MDI supports
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixMDIAimd::FixMDIAimd(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
FixMDIQM::FixMDIQM(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all(FLERR, "Illegal fix mdi/aimd command");
|
||||
|
||||
scalar_flag = 1;
|
||||
global_freq = 1;
|
||||
extscalar = 1;
|
||||
@ -40,8 +38,8 @@ FixMDIAimd::FixMDIAimd(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
|
||||
// check requirements for LAMMPS to work with MDI as an engine
|
||||
|
||||
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->natoms && atom->tag_consecutive() == 0)
|
||||
error->all(FLERR, "MDI engine requires consecutive atom IDs");
|
||||
|
||||
@ -50,7 +48,28 @@ FixMDIAimd::FixMDIAimd(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
int role;
|
||||
MDI_Get_role(&role);
|
||||
if (role != MDI_DRIVER)
|
||||
error->all(FLERR, "Must invoke LAMMPS as an MDI driver to use fix mdi/aimd");
|
||||
error->all(FLERR, "Must invoke LAMMPS as an MDI driver to use fix mdi/qm");
|
||||
|
||||
// optional args
|
||||
|
||||
addflag = 1;
|
||||
every = 1;
|
||||
|
||||
int iarg = 3;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"add") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix mdi/qm command");
|
||||
if (strcmp(arg[iarg],"yes") == 0) addflag = 1;
|
||||
else if (strcmp(arg[iarg],"no") == 0) addflag = 0;
|
||||
else error->all(FLERR,"Illegal fix mdi/qm command");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"every") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix mdi/qm command");
|
||||
every = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (every < 0) error->all(FLERR,"Illegal fix mdi/qm command");
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal fix mdi/qm command");
|
||||
}
|
||||
|
||||
// mdicomm will be one-time initialized in init()
|
||||
// cannot be done here for a plugin library, b/c mdi plugin command is later
|
||||
@ -78,7 +97,7 @@ FixMDIAimd::FixMDIAimd(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixMDIAimd::~FixMDIAimd()
|
||||
FixMDIQM::~FixMDIQM()
|
||||
{
|
||||
// send exit command to engine if it is a stand-alone code
|
||||
// for plugin, this happens in MDIPlugin::plugin_wrapper()
|
||||
@ -96,7 +115,7 @@ FixMDIAimd::~FixMDIAimd()
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int FixMDIAimd::setmask()
|
||||
int FixMDIQM::setmask()
|
||||
{
|
||||
int mask = 0;
|
||||
mask |= PRE_REVERSE;
|
||||
@ -107,7 +126,7 @@ int FixMDIAimd::setmask()
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIAimd::init()
|
||||
void FixMDIQM::init()
|
||||
{
|
||||
if (mdicomm != MDI_COMM_NULL) return;
|
||||
|
||||
@ -120,25 +139,27 @@ void FixMDIAimd::init()
|
||||
if (mdicomm == MDI_COMM_NULL) {
|
||||
plugin = 0;
|
||||
MDI_Accept_communicator(&mdicomm);
|
||||
if (mdicomm == MDI_COMM_NULL) error->all(FLERR, "MDI unable to connect to stand-alone engine");
|
||||
if (mdicomm == MDI_COMM_NULL)
|
||||
error->all(FLERR, "MDI unable to connect to stand-alone engine");
|
||||
} else {
|
||||
plugin = 1;
|
||||
int method;
|
||||
MDI_Get_method(&method, mdicomm);
|
||||
if (method != MDI_PLUGIN) error->all(FLERR, "MDI internal error for plugin engine");
|
||||
if (method != MDI_PLUGIN)
|
||||
error->all(FLERR, "MDI internal error for plugin engine");
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIAimd::setup(int vflag)
|
||||
void FixMDIQM::setup(int vflag)
|
||||
{
|
||||
post_force(vflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIAimd::setup_pre_reverse(int eflag, int vflag)
|
||||
void FixMDIQM::setup_pre_reverse(int eflag, int vflag)
|
||||
{
|
||||
pre_reverse(eflag, vflag);
|
||||
}
|
||||
@ -147,14 +168,14 @@ void FixMDIAimd::setup_pre_reverse(int eflag, int vflag)
|
||||
store eflag, so can use it in post_force to request energy
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIAimd::pre_reverse(int eflag, int /*vflag*/)
|
||||
void FixMDIQM::pre_reverse(int eflag, int /*vflag*/)
|
||||
{
|
||||
eflag_caller = eflag;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIAimd::post_force(int vflag)
|
||||
void FixMDIQM::post_force(int vflag)
|
||||
{
|
||||
int ilocal, ierr;
|
||||
double cell[9];
|
||||
@ -266,7 +287,7 @@ void FixMDIAimd::post_force(int vflag)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIAimd::min_post_force(int vflag)
|
||||
void FixMDIQM::min_post_force(int vflag)
|
||||
{
|
||||
post_force(vflag);
|
||||
}
|
||||
@ -275,7 +296,7 @@ void FixMDIAimd::min_post_force(int vflag)
|
||||
energy from MDI engine
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double FixMDIAimd::compute_scalar()
|
||||
double FixMDIQM::compute_scalar()
|
||||
{
|
||||
return engine_energy;
|
||||
}
|
||||
@ -284,12 +305,12 @@ double FixMDIAimd::compute_scalar()
|
||||
reallocate storage for all atoms if necessary
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIAimd::reallocate()
|
||||
void FixMDIQM::reallocate()
|
||||
{
|
||||
if (atom->natoms <= maxbuf) return;
|
||||
|
||||
if (3 * atom->natoms > MAXSMALLINT)
|
||||
error->all(FLERR, "Natoms too large to use with fix mdi/aimd");
|
||||
error->all(FLERR, "Natoms too large to use with fix mdi/qm");
|
||||
|
||||
maxbuf = atom->natoms;
|
||||
|
||||
@ -304,7 +325,7 @@ void FixMDIAimd::reallocate()
|
||||
MDI to/from LAMMPS conversion factors
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIAimd::unit_conversions()
|
||||
void FixMDIQM::unit_conversions()
|
||||
{
|
||||
double angstrom_to_bohr, kelvin_to_hartree, ev_to_hartree, second_to_aut;
|
||||
|
||||
@ -13,22 +13,22 @@
|
||||
|
||||
#ifdef FIX_CLASS
|
||||
// clang-format off
|
||||
FixStyle(mdi/aimd,FixMDIAimd);
|
||||
FixStyle(mdi/qm,FixMDIQM);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_FIX_MDI_AIMD_H
|
||||
#define LMP_FIX_MDI_AIMD_H
|
||||
#ifndef LMP_FIX_MDI_QM_H
|
||||
#define LMP_FIX_MDI_QM_H
|
||||
|
||||
#include "fix.h"
|
||||
#include <mdi.h>
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class FixMDIAimd : public Fix {
|
||||
class FixMDIQM : public Fix {
|
||||
public:
|
||||
FixMDIAimd(class LAMMPS *, int, char **);
|
||||
~FixMDIAimd();
|
||||
FixMDIQM(class LAMMPS *, int, char **);
|
||||
~FixMDIQM();
|
||||
int setmask();
|
||||
|
||||
void init();
|
||||
Reference in New Issue
Block a user