Merge branch 'kspace_zero' into plugin-add-run-min-style
This commit is contained in:
@ -94,10 +94,14 @@ add_library(zero2plugin MODULE zero2plugin.cpp pair_zero2.cpp bond_zero2.cpp
|
|||||||
angle_zero2.cpp dihedral_zero2.cpp improper_zero2.cpp)
|
angle_zero2.cpp dihedral_zero2.cpp improper_zero2.cpp)
|
||||||
target_link_libraries(zero2plugin PRIVATE lammps)
|
target_link_libraries(zero2plugin PRIVATE lammps)
|
||||||
|
|
||||||
|
add_library(kspaceplugin MODULE kspaceplugin.cpp kspace_zero2.cpp)
|
||||||
|
target_include_directories(kspaceplugin PRIVATE "${LAMMPS_HEADER_DIR}/KSPACE")
|
||||||
|
target_link_libraries(kspaceplugin PRIVATE lammps)
|
||||||
|
|
||||||
add_library(runminplugin MODULE runminplugin.cpp min_cg2.cpp verlet2.cpp)
|
add_library(runminplugin MODULE runminplugin.cpp min_cg2.cpp verlet2.cpp)
|
||||||
target_link_libraries(runminplugin PRIVATE lammps)
|
target_link_libraries(runminplugin PRIVATE lammps)
|
||||||
|
|
||||||
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin runminplugin PROPERTIES PREFIX "" SUFFIX ".so")
|
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin kspaceplugin runminplugin PROPERTIES PREFIX "" SUFFIX ".so")
|
||||||
|
|
||||||
# MacOS seems to need this
|
# MacOS seems to need this
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||||
@ -108,13 +112,13 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|||||||
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin
|
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin
|
||||||
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||||
if(CMAKE_CROSSCOMPILING)
|
if(CMAKE_CROSSCOMPILING)
|
||||||
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin runminplugin
|
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin kspaceplugin runminplugin
|
||||||
PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
|
PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin runminplugin PROPERTIES
|
set_target_properties(morse2plugin nve2plugin helloplugin zero2plugin kspaceplugin runminplugin PROPERTIES
|
||||||
LINK_FLAGS "-rdynamic")
|
LINK_FLAGS "-rdynamic")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_custom_target(plugins ALL ${CMAKE_COMMAND} -E echo "Building Plugins"
|
add_custom_target(plugins ALL ${CMAKE_COMMAND} -E echo "Building Plugins"
|
||||||
DEPENDS morse2plugin nve2plugin helloplugin zero2plugin morse2plugin runminplugin)
|
DEPENDS morse2plugin nve2plugin helloplugin zero2plugin morse2plugin kspaceplugin runminplugin)
|
||||||
|
|||||||
117
examples/plugins/kspace_zero2.cpp
Normal file
117
examples/plugins/kspace_zero2.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
|
LAMMPS development team: developers@lammps.org
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing author: Axel Kohlmeyer (Temple U)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "kspace_zero2.h"
|
||||||
|
|
||||||
|
#include "atom.h"
|
||||||
|
#include "comm.h"
|
||||||
|
#include "domain.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "force.h"
|
||||||
|
#include "pair.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
KSpaceZero2::KSpaceZero2(LAMMPS *lmp) : KSpace(lmp)
|
||||||
|
{
|
||||||
|
ewaldflag = 1;
|
||||||
|
pppmflag = 1;
|
||||||
|
msmflag = 1;
|
||||||
|
dispersionflag = 1;
|
||||||
|
tip4pflag = 1;
|
||||||
|
dipoleflag = 1;
|
||||||
|
spinflag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
KSpaceZero2::~KSpaceZero2()
|
||||||
|
{
|
||||||
|
fprintf(stderr, "In destructor for KSpace zero2. This = %p\n", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void KSpaceZero2::settings(int narg, char **arg)
|
||||||
|
{
|
||||||
|
if (narg != 1) error->all(FLERR, "Illegal kspace_style {} command", force->kspace_style);
|
||||||
|
|
||||||
|
accuracy_relative = fabs(utils::numeric(FLERR, arg[0], false, lmp));
|
||||||
|
if (accuracy_relative > 1.0)
|
||||||
|
error->all(FLERR, "Invalid relative accuracy {:g} for kspace_style {}", accuracy_relative,
|
||||||
|
force->kspace_style);
|
||||||
|
if ((narg != 0) && (narg != 1)) error->all(FLERR, "Illegal kspace_style command");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void KSpaceZero2::init()
|
||||||
|
{
|
||||||
|
if (comm->me == 0) utils::logmesg(lmp, "Dummy KSpace initialization ...\n");
|
||||||
|
|
||||||
|
// error checks
|
||||||
|
|
||||||
|
if (force->pair == nullptr) error->all(FLERR, "KSpace solver requires a pair style");
|
||||||
|
if (!atom->q_flag) error->all(FLERR, "KSpace style zero2 requires atom attribute q");
|
||||||
|
|
||||||
|
// compute two charge force
|
||||||
|
|
||||||
|
two_charge();
|
||||||
|
|
||||||
|
int itmp;
|
||||||
|
auto p_cutoff = (double *) force->pair->extract("cut_coul", itmp);
|
||||||
|
if (p_cutoff == nullptr) error->all(FLERR, "KSpace style is incompatible with Pair style");
|
||||||
|
double cutoff = *p_cutoff;
|
||||||
|
|
||||||
|
qsum_qsq();
|
||||||
|
|
||||||
|
accuracy = accuracy_relative * two_charge_force;
|
||||||
|
|
||||||
|
// make initial g_ewald estimate
|
||||||
|
// based on desired accuracy and real space cutoff
|
||||||
|
// fluid-occupied volume used to estimate real-space error
|
||||||
|
// zprd used rather than zprd_slab
|
||||||
|
|
||||||
|
if (!gewaldflag) {
|
||||||
|
if (accuracy <= 0.0) error->all(FLERR, "KSpace accuracy must be > 0");
|
||||||
|
if (q2 == 0.0) error->all(FLERR, "Must use 'kspace_modify gewald' for uncharged system");
|
||||||
|
g_ewald = accuracy * sqrt(atom->natoms * cutoff * domain->xprd * domain->yprd * domain->zprd) /
|
||||||
|
(2.0 * q2);
|
||||||
|
if (g_ewald >= 1.0)
|
||||||
|
g_ewald = (1.35 - 0.15 * log(accuracy)) / cutoff;
|
||||||
|
else
|
||||||
|
g_ewald = sqrt(-log(g_ewald)) / cutoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comm->me == 0) std::string mesg = fmt::format(" G vector (1/distance) = {:.8g}\n", g_ewald);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void KSpaceZero2::setup()
|
||||||
|
{
|
||||||
|
if (comm->me == 0) utils::logmesg(lmp, "Dummy KSpace setup\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void KSpaceZero2::compute(int eflag, int vflag)
|
||||||
|
{
|
||||||
|
ev_init(eflag, vflag);
|
||||||
|
}
|
||||||
33
examples/plugins/kspace_zero2.h
Normal file
33
examples/plugins/kspace_zero2.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
https://www.lammps.org/ Sandia National Laboratories
|
||||||
|
LAMMPS development team: developers@lammps.org
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifndef LMP_KSPACE_ZERO2_H
|
||||||
|
#define LMP_KSPACE_ZERO2_H
|
||||||
|
|
||||||
|
#include "kspace.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
class KSpaceZero2 : public KSpace {
|
||||||
|
public:
|
||||||
|
KSpaceZero2(class LAMMPS *);
|
||||||
|
~KSpaceZero2() override;
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
void setup() override;
|
||||||
|
void settings(int, char **) override;
|
||||||
|
|
||||||
|
void compute(int, int) override;
|
||||||
|
};
|
||||||
|
} // namespace LAMMPS_NS
|
||||||
|
#endif
|
||||||
35
examples/plugins/kspaceplugin.cpp
Normal file
35
examples/plugins/kspaceplugin.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
#include "lammpsplugin.h"
|
||||||
|
|
||||||
|
#include "comm.h"
|
||||||
|
#include "command.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "kspace_zero2.h"
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
static KSpace *zero2creator(LAMMPS *lmp)
|
||||||
|
{
|
||||||
|
KSpace *ptr = (KSpace *) new KSpaceZero2(lmp);
|
||||||
|
fprintf(stderr, "Created zero2 instance at %p\n", ptr);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc)
|
||||||
|
{
|
||||||
|
lammpsplugin_t plugin;
|
||||||
|
lammpsplugin_regfunc register_plugin = (lammpsplugin_regfunc) regfunc;
|
||||||
|
|
||||||
|
plugin.version = LAMMPS_VERSION;
|
||||||
|
plugin.style = "kspace";
|
||||||
|
plugin.name = "zero2";
|
||||||
|
plugin.info = "zero2 KSpace style v1.0";
|
||||||
|
plugin.author = "Axel Kohlmeyer (akohlmey@gmail.com)";
|
||||||
|
plugin.creator.v1 = (lammpsplugin_factory1 *) &zero2creator;
|
||||||
|
plugin.handle = handle;
|
||||||
|
(*register_plugin)(&plugin, lmp);
|
||||||
|
}
|
||||||
117
src/KSPACE/kspace_zero.cpp
Normal file
117
src/KSPACE/kspace_zero.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
|
LAMMPS development team: developers@lammps.org
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing author: Axel Kohlmeyer (Temple U)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "kspace_zero.h"
|
||||||
|
|
||||||
|
#include "atom.h"
|
||||||
|
#include "comm.h"
|
||||||
|
#include "domain.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "force.h"
|
||||||
|
#include "pair.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
KSpaceZero::KSpaceZero(LAMMPS *lmp) : KSpace(lmp)
|
||||||
|
{
|
||||||
|
ewaldflag = 1;
|
||||||
|
pppmflag = 1;
|
||||||
|
msmflag = 1;
|
||||||
|
dispersionflag = 1;
|
||||||
|
tip4pflag = 1;
|
||||||
|
dipoleflag = 1;
|
||||||
|
spinflag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
KSpaceZero::~KSpaceZero()
|
||||||
|
{
|
||||||
|
fprintf(stderr, "In destructor for KSpace zero. This = %p\n", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void KSpaceZero::settings(int narg, char **arg)
|
||||||
|
{
|
||||||
|
if (narg != 1) error->all(FLERR, "Illegal kspace_style {} command", force->kspace_style);
|
||||||
|
|
||||||
|
accuracy_relative = fabs(utils::numeric(FLERR, arg[0], false, lmp));
|
||||||
|
if (accuracy_relative > 1.0)
|
||||||
|
error->all(FLERR, "Invalid relative accuracy {:g} for kspace_style {}", accuracy_relative,
|
||||||
|
force->kspace_style);
|
||||||
|
if ((narg != 0) && (narg != 1)) error->all(FLERR, "Illegal kspace_style command");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void KSpaceZero::init()
|
||||||
|
{
|
||||||
|
if (comm->me == 0) utils::logmesg(lmp, "Dummy KSpace initialization ...\n");
|
||||||
|
|
||||||
|
// error checks
|
||||||
|
|
||||||
|
if (force->pair == nullptr) error->all(FLERR, "KSpace solver requires a pair style");
|
||||||
|
if (!atom->q_flag) error->all(FLERR, "KSpace style zero requires atom attribute q");
|
||||||
|
|
||||||
|
// compute two charge force
|
||||||
|
|
||||||
|
two_charge();
|
||||||
|
|
||||||
|
int itmp;
|
||||||
|
auto p_cutoff = (double *) force->pair->extract("cut_coul", itmp);
|
||||||
|
if (p_cutoff == nullptr) error->all(FLERR, "KSpace style is incompatible with Pair style");
|
||||||
|
double cutoff = *p_cutoff;
|
||||||
|
|
||||||
|
qsum_qsq();
|
||||||
|
|
||||||
|
accuracy = accuracy_relative * two_charge_force;
|
||||||
|
|
||||||
|
// make initial g_ewald estimate
|
||||||
|
// based on desired accuracy and real space cutoff
|
||||||
|
// fluid-occupied volume used to estimate real-space error
|
||||||
|
// zprd used rather than zprd_slab
|
||||||
|
|
||||||
|
if (!gewaldflag) {
|
||||||
|
if (accuracy <= 0.0) error->all(FLERR, "KSpace accuracy must be > 0");
|
||||||
|
if (q2 == 0.0) error->all(FLERR, "Must use 'kspace_modify gewald' for uncharged system");
|
||||||
|
g_ewald = accuracy * sqrt(atom->natoms * cutoff * domain->xprd * domain->yprd * domain->zprd) /
|
||||||
|
(2.0 * q2);
|
||||||
|
if (g_ewald >= 1.0)
|
||||||
|
g_ewald = (1.35 - 0.15 * log(accuracy)) / cutoff;
|
||||||
|
else
|
||||||
|
g_ewald = sqrt(-log(g_ewald)) / cutoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comm->me == 0) std::string mesg = fmt::format(" G vector (1/distance) = {:.8g}\n", g_ewald);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void KSpaceZero::setup()
|
||||||
|
{
|
||||||
|
if (comm->me == 0) utils::logmesg(lmp, "Dummy KSpace setup\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void KSpaceZero::compute(int eflag, int vflag)
|
||||||
|
{
|
||||||
|
ev_init(eflag, vflag);
|
||||||
|
}
|
||||||
40
src/KSPACE/kspace_zero.h
Normal file
40
src/KSPACE/kspace_zero.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
https://www.lammps.org/ Sandia National Laboratories
|
||||||
|
LAMMPS development team: developers@lammps.org
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef KSPACE_CLASS
|
||||||
|
// clang-format off
|
||||||
|
KSpaceStyle(zero,KSpaceZero);
|
||||||
|
// clang-format on
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifndef LMP_KSPACE_ZERO_H
|
||||||
|
#define LMP_KSPACE_ZERO_H
|
||||||
|
|
||||||
|
#include "kspace.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
class KSpaceZero : public KSpace {
|
||||||
|
public:
|
||||||
|
KSpaceZero(class LAMMPS *);
|
||||||
|
~KSpaceZero() override;
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
void setup() override;
|
||||||
|
void settings(int, char **) override;
|
||||||
|
|
||||||
|
void compute(int, int) override;
|
||||||
|
};
|
||||||
|
} // namespace LAMMPS_NS
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@ -33,15 +33,15 @@ static constexpr double SMALL = 0.00001;
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
KSpace::KSpace(LAMMPS *lmp) : Pointers(lmp)
|
KSpace::KSpace(LAMMPS *lmp) :
|
||||||
|
Pointers(lmp), eatom(nullptr), vatom(nullptr), gcons(nullptr), dgcons(nullptr)
|
||||||
{
|
{
|
||||||
order_allocated = 0;
|
order_allocated = 0;
|
||||||
energy = 0.0;
|
energy = 0.0;
|
||||||
virial[0] = virial[1] = virial[2] = virial[3] = virial[4] = virial[5] = 0.0;
|
virial[0] = virial[1] = virial[2] = virial[3] = virial[4] = virial[5] = 0.0;
|
||||||
|
|
||||||
triclinic_support = 1;
|
triclinic_support = 1;
|
||||||
ewaldflag = pppmflag = msmflag = dispersionflag = tip4pflag =
|
ewaldflag = pppmflag = msmflag = dispersionflag = tip4pflag = dipoleflag = spinflag = 0;
|
||||||
dipoleflag = spinflag = 0;
|
|
||||||
compute_flag = 1;
|
compute_flag = 1;
|
||||||
group_group_enable = 0;
|
group_group_enable = 0;
|
||||||
stagger_flag = 0;
|
stagger_flag = 0;
|
||||||
@ -83,14 +83,17 @@ KSpace::KSpace(LAMMPS *lmp) : Pointers(lmp)
|
|||||||
accuracy_real_6 = -1.0;
|
accuracy_real_6 = -1.0;
|
||||||
accuracy_kspace_6 = -1.0;
|
accuracy_kspace_6 = -1.0;
|
||||||
|
|
||||||
|
qqrd2e = force->qqrd2e;
|
||||||
|
g_ewald = g_ewald_6 = 0.0;
|
||||||
|
scale = 1.0;
|
||||||
|
|
||||||
neighrequest_flag = 1;
|
neighrequest_flag = 1;
|
||||||
mixflag = 0;
|
mixflag = 0;
|
||||||
|
|
||||||
splittol = 1.0e-6;
|
splittol = 1.0e-6;
|
||||||
|
scale = 1.0;
|
||||||
|
|
||||||
maxeatom = maxvatom = 0;
|
maxeatom = maxvatom = 0;
|
||||||
eatom = nullptr;
|
|
||||||
vatom = nullptr;
|
|
||||||
centroidstressflag = CENTROID_NOTAVAIL;
|
centroidstressflag = CENTROID_NOTAVAIL;
|
||||||
|
|
||||||
execution_space = Host;
|
execution_space = Host;
|
||||||
|
|||||||
Reference in New Issue
Block a user