cosmetic changes to comments and code structure
This commit is contained in:
@ -294,7 +294,10 @@ LAMMPS can also be used as an MDI driver in other unit choices it
|
||||
supports, e.g. *lj*, but then no unit conversion to MDI units is
|
||||
performed.
|
||||
|
||||
If this fix is used in conjuction with a QM code that does not support periodic boundary conditions (more specifically, a QM code that does not support the ``>CELL`` MDI command), the LAMMPS input file must specify non-periodic boundary conditions.
|
||||
If this fix is used in conjuction with a QM code that does not support
|
||||
periodic boundary conditions (more specifically, a QM code that does
|
||||
not support the ``>CELL`` MDI command), the LAMMPS system must be
|
||||
fully non-periodic. I.e. no dimension of the system can be periodic.
|
||||
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
@ -261,7 +261,10 @@ 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.
|
||||
|
||||
If this fix is used in conjuction with a QM code that does not support periodic boundary conditions (more specifically, a QM code that does not support the ``>CELL`` MDI command), the LAMMPS input file must specify non-periodic boundary conditions.
|
||||
If this fix is used in conjuction with a QM code that does not support
|
||||
periodic boundary conditions (more specifically, a QM code that does
|
||||
not support the ``>CELL`` MDI command), the LAMMPS system must be
|
||||
fully non-periodic. I.e. no dimension of the system can be periodic.
|
||||
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
@ -512,35 +512,11 @@ void FixMDIQM::post_force(int vflag)
|
||||
ierr = MDI_Send(&xqm[0][0], 3 * nqm, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: >COORDS data");
|
||||
|
||||
// request potential energy from MDI engine
|
||||
// request QM energy from MDI engine
|
||||
// this triggers engine to perform QM calculation
|
||||
// qm_energy = fix output for global QM energy
|
||||
// sets qm_energy = fix output for global QM energy
|
||||
|
||||
if (pe_exists && keelec_exists) {
|
||||
int pe_energy, keelec_energy;
|
||||
|
||||
// get the total potential energy
|
||||
ierr = MDI_Send_command("<PE", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <PE command");
|
||||
ierr = MDI_Recv(&pe_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <PE data");
|
||||
|
||||
// get the kinetic energy of the electrons
|
||||
ierr = MDI_Send_command("<KE_ELEC", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <KE_ELEC command");
|
||||
ierr = MDI_Recv(&keelec_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <KE_ELEC data");
|
||||
|
||||
qm_energy = pe_energy + keelec_energy;
|
||||
} else {
|
||||
// get the total energy
|
||||
ierr = MDI_Send_command("<ENERGY", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <ENERGY command");
|
||||
ierr = MDI_Recv(&qm_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <ENERGY data");
|
||||
}
|
||||
MPI_Bcast(&qm_energy, 1, MPI_DOUBLE, 0, world);
|
||||
qm_energy *= mdi2lmp_energy;
|
||||
request_qm_energy();
|
||||
|
||||
// request forces from MDI engine
|
||||
|
||||
@ -1008,9 +984,9 @@ void FixMDIQM::send_box()
|
||||
{
|
||||
int ierr;
|
||||
|
||||
// Only send the cell dimensions if this is a periodic simulation
|
||||
if (domain->xperiodic == 1 && domain->yperiodic == 1 && domain->zperiodic == 1) {
|
||||
|
||||
// only send cell dimensions if fully periodic simulation
|
||||
|
||||
if (domain->nonperiodic == 0) {
|
||||
if (celldispl_exists) {
|
||||
ierr = MDI_Send_command(">CELL_DISPL", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: >CELL_DISPL command");
|
||||
@ -1023,17 +999,49 @@ void FixMDIQM::send_box()
|
||||
ierr = MDI_Send(qm_cell, 9, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: >CELL data");
|
||||
|
||||
} else {
|
||||
|
||||
if (domain->xperiodic == 1 || domain->yperiodic == 1 || domain->zperiodic == 1) {
|
||||
|
||||
error->all(FLERR,
|
||||
"MDI: The QM driver does not work for simulations with both periodic and "
|
||||
"non-periodic dimensions.");
|
||||
}
|
||||
} else if (domain->xperiodic == 1 || domain->yperiodic == 1 ||
|
||||
domain->zperiodic == 1) {
|
||||
error->all(FLERR,"MDI requires fully periodic or fully non-periodic system");
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
request QM energy from MDI engine
|
||||
set qm_energy = fix output for global QM energy
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIQM::request_qm_energy()
|
||||
{
|
||||
int ierr;
|
||||
|
||||
// QM energy = <PE + <KE_ELEC or <ENERGY, depending on engine options
|
||||
|
||||
if (pe_exists && keelec_exists) {
|
||||
int pe_energy, keelec_energy;
|
||||
|
||||
ierr = MDI_Send_command("<PE", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <PE command");
|
||||
ierr = MDI_Recv(&pe_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <PE data");
|
||||
|
||||
ierr = MDI_Send_command("<KE_ELEC", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <KE_ELEC command");
|
||||
ierr = MDI_Recv(&keelec_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <KE_ELEC data");
|
||||
|
||||
qm_energy = pe_energy + keelec_energy;
|
||||
|
||||
} else {
|
||||
ierr = MDI_Send_command("<ENERGY", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <ENERGY command");
|
||||
ierr = MDI_Recv(&qm_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <ENERGY data");
|
||||
}
|
||||
|
||||
MPI_Bcast(&qm_energy, 1, MPI_DOUBLE, 0, world);
|
||||
qm_energy *= mdi2lmp_energy;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
MDI to/from LAMMPS conversion factors
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -105,6 +105,8 @@ class FixMDIQM : public Fix {
|
||||
void send_elements();
|
||||
void send_box();
|
||||
|
||||
void request_qm_energy();
|
||||
|
||||
void unit_conversions();
|
||||
};
|
||||
|
||||
|
||||
@ -726,11 +726,11 @@ void FixMDIQMMM::pre_force(int vflag)
|
||||
ierr = MDI_Send(qpotential, nqm, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: >POTENTIAL_AT_NUCLEI data");
|
||||
|
||||
// request QM potential energy from MDI engine
|
||||
// request QM energy from MDI engine
|
||||
// this triggers engine to perform QM calculation
|
||||
// qm_energy = fix output for global QM energy
|
||||
// sets qm_energy = fix output for global QM energy
|
||||
|
||||
get_qm_energy();
|
||||
request_qm_energy();
|
||||
|
||||
// request forces on QM atoms from MDI engine
|
||||
|
||||
@ -886,11 +886,11 @@ void FixMDIQMMM::post_force_direct(int vflag)
|
||||
ierr = MDI_Send(&xmm[0][0], 3 * nmm, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: >CLATTICE data");
|
||||
|
||||
// request QM potential energy from MDI engine
|
||||
// request QM energy from MDI engine
|
||||
// this triggers engine to perform QM calculation
|
||||
// qm_energy = fix output for global QM energy
|
||||
// sets qm_energy = fix output for global QM energy
|
||||
|
||||
get_qm_energy();
|
||||
request_qm_energy();
|
||||
|
||||
// request forces on QM atoms from MDI engine
|
||||
|
||||
@ -1767,9 +1767,9 @@ void FixMDIQMMM::send_box()
|
||||
{
|
||||
int ierr;
|
||||
|
||||
// Only send the cell dimensions if this is a periodic simulation
|
||||
if (domain->xperiodic == 1 && domain->yperiodic == 1 && domain->zperiodic == 1) {
|
||||
|
||||
// only send cell dimensions if fully periodic simulation
|
||||
|
||||
if (domain->nonperiodic == 0) {
|
||||
if (celldispl_exists) {
|
||||
ierr = MDI_Send_command(">CELL_DISPL", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: >CELL_DISPL command");
|
||||
@ -1782,52 +1782,12 @@ void FixMDIQMMM::send_box()
|
||||
ierr = MDI_Send(qm_cell, 9, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: >CELL data");
|
||||
|
||||
} else {
|
||||
|
||||
if (domain->xperiodic == 1 || domain->yperiodic == 1 || domain->zperiodic == 1) {
|
||||
|
||||
error->all(FLERR,
|
||||
"MDI: The QM driver does not work for simulations with both periodic and "
|
||||
"non-periodic dimensions.");
|
||||
}
|
||||
} else if (domain->xperiodic == 1 || domain->yperiodic == 1 ||
|
||||
domain->zperiodic == 1) {
|
||||
error->all(FLERR,"MDI requires fully periodic or fully non-periodic system");
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
get the energy of the QM system
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIQMMM::get_qm_energy()
|
||||
{
|
||||
int ierr;
|
||||
|
||||
if (pe_exists && keelec_exists) {
|
||||
int pe_energy, keelec_energy;
|
||||
|
||||
// get the total potential energy
|
||||
ierr = MDI_Send_command("<PE", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <PE command");
|
||||
ierr = MDI_Recv(&pe_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <PE data");
|
||||
|
||||
// get the kinetic energy of the electrons
|
||||
ierr = MDI_Send_command("<KE_ELEC", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <KE_ELEC command");
|
||||
ierr = MDI_Recv(&keelec_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <KE_ELEC data");
|
||||
|
||||
qm_energy = pe_energy + keelec_energy;
|
||||
} else {
|
||||
// get the total energy
|
||||
ierr = MDI_Send_command("<ENERGY", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <ENERGY command");
|
||||
ierr = MDI_Recv(&qm_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <ENERGY data");
|
||||
}
|
||||
MPI_Bcast(&qm_energy, 1, MPI_DOUBLE, 0, world);
|
||||
qm_energy *= mdi2lmp_energy;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
send LAMMPS MM atom count to MDI engine
|
||||
------------------------------------------------------------------------- */
|
||||
@ -1876,6 +1836,43 @@ void FixMDIQMMM::send_charges_mm()
|
||||
if (ierr) error->all(FLERR, "MDI: >LATTICE data");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
request QM energy from MDI engine
|
||||
set qm_energy = fix output for global QM energy
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixMDIQMMM::request_qm_energy()
|
||||
{
|
||||
int ierr;
|
||||
|
||||
// QM energy = <PE + <KE_ELEC or <ENERGY, depending on engine options
|
||||
|
||||
if (pe_exists && keelec_exists) {
|
||||
int pe_energy, keelec_energy;
|
||||
|
||||
ierr = MDI_Send_command("<PE", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <PE command");
|
||||
ierr = MDI_Recv(&pe_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <PE data");
|
||||
|
||||
ierr = MDI_Send_command("<KE_ELEC", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <KE_ELEC command");
|
||||
ierr = MDI_Recv(&keelec_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <KE_ELEC data");
|
||||
|
||||
qm_energy = pe_energy + keelec_energy;
|
||||
|
||||
} else {
|
||||
ierr = MDI_Send_command("<ENERGY", mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <ENERGY command");
|
||||
ierr = MDI_Recv(&qm_energy, 1, MDI_DOUBLE, mdicomm);
|
||||
if (ierr) error->all(FLERR, "MDI: <ENERGY data");
|
||||
}
|
||||
|
||||
MPI_Bcast(&qm_energy, 1, MPI_DOUBLE, 0, world);
|
||||
qm_energy *= mdi2lmp_energy;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
MDI to/from LAMMPS conversion factors
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -156,7 +156,7 @@ class FixMDIQMMM : public Fix {
|
||||
void send_elements_mm();
|
||||
void send_charges_mm();
|
||||
|
||||
void get_qm_energy();
|
||||
void request_qm_energy();
|
||||
|
||||
void unit_conversions();
|
||||
};
|
||||
|
||||
@ -1533,10 +1533,9 @@ void MDIEngine::send_pe()
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
<KE_ELEC command
|
||||
send the kinetic energy of the electrons
|
||||
because lammps does not model electrons explicitly, this is zero
|
||||
this is primarily for use when LAMMPS is filling a role that would
|
||||
normally be filled by a QM code
|
||||
send kinetic energy of the electrons
|
||||
zero for LAMMPS, because it does not model electrons explicitly
|
||||
for compatibiity with QM engines which support this command
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
void MDIEngine::send_ke_elec()
|
||||
|
||||
Reference in New Issue
Block a user