Merge pull request #3219 from akohlmey/region-lookup-refactor
Region lookup refactor
This commit is contained in:
@ -3,7 +3,6 @@ Bonded particle models
|
|||||||
|
|
||||||
The BPM package implements bonded particle models which can be used to
|
The BPM package implements bonded particle models which can be used to
|
||||||
simulate mesoscale solids. Solids are constructed as a collection of
|
simulate mesoscale solids. Solids are constructed as a collection of
|
||||||
|
|
||||||
particles which each represent a coarse-grained region of space much
|
particles which each represent a coarse-grained region of space much
|
||||||
larger than the atomistic scale. Particles within a solid region are
|
larger than the atomistic scale. Particles within a solid region are
|
||||||
then connected by a network of bonds to provide solid elasticity.
|
then connected by a network of bonds to provide solid elasticity.
|
||||||
@ -47,9 +46,7 @@ this, LAMMPS requires :doc:`newton <newton>` bond off such that all
|
|||||||
processors containing an atom know when a bond breaks. Additionally,
|
processors containing an atom know when a bond breaks. Additionally,
|
||||||
one must do either (A) or (B).
|
one must do either (A) or (B).
|
||||||
|
|
||||||
(A)
|
A) Use the following special bond settings
|
||||||
|
|
||||||
Use the following special bond settings
|
|
||||||
|
|
||||||
.. code-block:: LAMMPS
|
.. code-block:: LAMMPS
|
||||||
|
|
||||||
@ -64,12 +61,10 @@ charges in BPM models, setting a nonzero coul weight for 1-2 bonds
|
|||||||
ensures all bonded neighbors are still included in the neighbor list
|
ensures all bonded neighbors are still included in the neighbor list
|
||||||
in case bonds break between neighbor list builds.
|
in case bonds break between neighbor list builds.
|
||||||
|
|
||||||
(B)
|
B) Alternatively, one can simply overlay pair interactions such that all
|
||||||
|
bonded particles also feel pair interactions. This can be
|
||||||
Alternatively, one can simply overlay pair interactions such that all
|
accomplished by using the *overlay/pair* keyword present in all bpm
|
||||||
bonded particles also feel pair interactions. This can be accomplished
|
bond styles and by using the following special bond settings
|
||||||
by using the *overlay/pair* keyword present in all bpm bond styles and
|
|
||||||
by using the following special bond settings
|
|
||||||
|
|
||||||
.. code-block:: LAMMPS
|
.. code-block:: LAMMPS
|
||||||
|
|
||||||
|
|||||||
@ -305,7 +305,7 @@ with fix_adapt are
|
|||||||
+------------------------------------+-------+-----------------+
|
+------------------------------------+-------+-----------------+
|
||||||
| :doc:`fene <bond_fene>` | k,r0 | type bonds |
|
| :doc:`fene <bond_fene>` | k,r0 | type bonds |
|
||||||
+------------------------------------+-------+-----------------+
|
+------------------------------------+-------+-----------------+
|
||||||
| :doc:`fene/nm <bond_fene_nm>` | k,r0 | type bonds |
|
| :doc:`fene/nm <bond_fene>` | k,r0 | type bonds |
|
||||||
+------------------------------------+-------+-----------------+
|
+------------------------------------+-------+-----------------+
|
||||||
| :doc:`gromos <bond_gromos>` | k,r0 | type bonds |
|
| :doc:`gromos <bond_gromos>` | k,r0 | type bonds |
|
||||||
+------------------------------------+-------+-----------------+
|
+------------------------------------+-------+-----------------+
|
||||||
|
|||||||
@ -36,7 +36,7 @@ are (full) periodic boundary conditions and no other "manipulations"
|
|||||||
of the system (e.g. fixes that modify forces or velocities).
|
of the system (e.g. fixes that modify forces or velocities).
|
||||||
|
|
||||||
This fix invokes the velocity form of the
|
This fix invokes the velocity form of the
|
||||||
Störmer-Verlet time integration algorithm (velocity-Verlet). Other
|
Stoermer-Verlet time integration algorithm (velocity-Verlet). Other
|
||||||
time integration options can be invoked using the :doc:`run_style <run_style>` command.
|
time integration options can be invoked using the :doc:`run_style <run_style>` command.
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|||||||
@ -68,7 +68,7 @@ Choose the style of time integrator used for molecular dynamics
|
|||||||
simulations performed by LAMMPS.
|
simulations performed by LAMMPS.
|
||||||
|
|
||||||
The *verlet* style is the velocity form of the
|
The *verlet* style is the velocity form of the
|
||||||
Störmer-Verlet time integration algorithm (velocity-Verlet)
|
Stoermer-Verlet time integration algorithm (velocity-Verlet)
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|||||||
@ -315,6 +315,7 @@ borophene
|
|||||||
Botero
|
Botero
|
||||||
Botu
|
Botu
|
||||||
Bouguet
|
Bouguet
|
||||||
|
Bourasseau
|
||||||
Bourne
|
Bourne
|
||||||
boxcolor
|
boxcolor
|
||||||
boxhi
|
boxhi
|
||||||
@ -342,6 +343,7 @@ Broglie
|
|||||||
brownian
|
brownian
|
||||||
brownw
|
brownw
|
||||||
Broyden
|
Broyden
|
||||||
|
Brusselle
|
||||||
Bryantsev
|
Bryantsev
|
||||||
Btarget
|
Btarget
|
||||||
btype
|
btype
|
||||||
@ -674,6 +676,7 @@ Deresiewicz
|
|||||||
Derjagin
|
Derjagin
|
||||||
Derjaguin
|
Derjaguin
|
||||||
Derlet
|
Derlet
|
||||||
|
Desbiens
|
||||||
Deserno
|
Deserno
|
||||||
Destree
|
Destree
|
||||||
destructor
|
destructor
|
||||||
@ -787,6 +790,7 @@ Dullweber
|
|||||||
dumpfile
|
dumpfile
|
||||||
Dunbrack
|
Dunbrack
|
||||||
Dunweg
|
Dunweg
|
||||||
|
Dupend
|
||||||
Dupont
|
Dupont
|
||||||
dUs
|
dUs
|
||||||
dV
|
dV
|
||||||
@ -1669,6 +1673,7 @@ Kusters
|
|||||||
Kutta
|
Kutta
|
||||||
Kuznetsov
|
Kuznetsov
|
||||||
kx
|
kx
|
||||||
|
Lachet
|
||||||
Lackmann
|
Lackmann
|
||||||
Ladd
|
Ladd
|
||||||
lagrangian
|
lagrangian
|
||||||
@ -3188,6 +3193,7 @@ stochastically
|
|||||||
stochasticity
|
stochasticity
|
||||||
Stockmayer
|
Stockmayer
|
||||||
Stoddard
|
Stoddard
|
||||||
|
Stoermer
|
||||||
stoichiometric
|
stoichiometric
|
||||||
stoichiometry
|
stoichiometry
|
||||||
Stokesian
|
Stokesian
|
||||||
@ -3665,6 +3671,7 @@ Wittmaack
|
|||||||
wn
|
wn
|
||||||
Wolde
|
Wolde
|
||||||
workflow
|
workflow
|
||||||
|
workflows
|
||||||
Workum
|
Workum
|
||||||
Worley
|
Worley
|
||||||
Wriggers
|
Wriggers
|
||||||
|
|||||||
@ -387,7 +387,7 @@ double LammpsInterface::atom_quantity_conversion(FundamentalAtomQuantity quantit
|
|||||||
|
|
||||||
int LammpsInterface::dimension() const { return lammps_->domain->dimension; }
|
int LammpsInterface::dimension() const { return lammps_->domain->dimension; }
|
||||||
|
|
||||||
int LammpsInterface::nregion() const { return lammps_->domain->nregion; }
|
int LammpsInterface::nregion() const { return lammps_->domain->get_region_list().size(); }
|
||||||
|
|
||||||
void LammpsInterface::box_bounds(double & boxxlo, double & boxxhi,
|
void LammpsInterface::box_bounds(double & boxxlo, double & boxxhi,
|
||||||
double & boxylo, double & boxyhi,
|
double & boxylo, double & boxyhi,
|
||||||
@ -528,13 +528,14 @@ void LammpsInterface::box_periodicity(int & xperiodic,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int LammpsInterface::region_id(const char *regionName) const {
|
int LammpsInterface::region_id(const char *regionName) const {
|
||||||
int nregion = this->nregion();
|
auto regions = lammps_->domain->get_region_list();
|
||||||
for (int iregion = 0; iregion < nregion; iregion++) {
|
int iregion = 0;
|
||||||
if (strcmp(regionName, region_name(iregion)) == 0) {
|
for (auto reg : regions) {
|
||||||
|
if (strcmp(regionName, reg->id) == 0) {
|
||||||
return iregion;
|
return iregion;
|
||||||
}
|
}
|
||||||
|
++iregion;
|
||||||
}
|
}
|
||||||
throw ATC_Error("Region has not been defined");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1322,61 +1323,73 @@ int** LammpsInterface::bond_list() const { return lammps_->neighbor->bondlist;
|
|||||||
|
|
||||||
char * LammpsInterface::region_name(int iRegion) const
|
char * LammpsInterface::region_name(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->id;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * LammpsInterface::region_style(int iRegion) const
|
char * LammpsInterface::region_style(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->style;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->style;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_xlo(int iRegion) const
|
double LammpsInterface::region_xlo(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->extent_xlo;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->extent_xlo;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_xhi(int iRegion) const
|
double LammpsInterface::region_xhi(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->extent_xhi;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->extent_xhi;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_ylo(int iRegion) const
|
double LammpsInterface::region_ylo(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->extent_ylo;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->extent_ylo;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_yhi(int iRegion) const
|
double LammpsInterface::region_yhi(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->extent_yhi;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->extent_yhi;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_zlo(int iRegion) const
|
double LammpsInterface::region_zlo(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->extent_zlo;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->extent_zlo;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_zhi(int iRegion) const
|
double LammpsInterface::region_zhi(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->extent_zhi;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->extent_zhi;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_xscale(int iRegion) const
|
double LammpsInterface::region_xscale(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->xscale;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->xscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_yscale(int iRegion) const
|
double LammpsInterface::region_yscale(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->yscale;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->yscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
double LammpsInterface::region_zscale(int iRegion) const
|
double LammpsInterface::region_zscale(int iRegion) const
|
||||||
{
|
{
|
||||||
return lammps_->domain->regions[iRegion]->zscale;
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->zscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LammpsInterface::region_match(int iRegion, double x, double y, double z) const {
|
int LammpsInterface::region_match(int iRegion, double x, double y, double z) const {
|
||||||
return lammps_->domain->regions[iRegion]->match(x,y,z);
|
auto regions = lammps_->domain->get_region_list();
|
||||||
|
return regions[iRegion]->match(x,y,z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
|||||||
@ -221,8 +221,10 @@ void DumpCustomADIOS::init_style()
|
|||||||
int icol = 0;
|
int icol = 0;
|
||||||
for (auto item : utils::split_words(columns_default)) {
|
for (auto item : utils::split_words(columns_default)) {
|
||||||
if (combined.size()) combined += " ";
|
if (combined.size()) combined += " ";
|
||||||
if (keyword_user[icol].size()) combined += keyword_user[icol];
|
if (keyword_user[icol].size())
|
||||||
else combined += item;
|
combined += keyword_user[icol];
|
||||||
|
else
|
||||||
|
combined += item;
|
||||||
++icol;
|
++icol;
|
||||||
}
|
}
|
||||||
columns = utils::strdup(combined);
|
columns = utils::strdup(combined);
|
||||||
@ -249,34 +251,30 @@ void DumpCustomADIOS::init_style()
|
|||||||
*/
|
*/
|
||||||
// find current ptr for each compute,fix,variable
|
// find current ptr for each compute,fix,variable
|
||||||
// check that fix frequency is acceptable
|
// check that fix frequency is acceptable
|
||||||
int icompute;
|
|
||||||
for (int i = 0; i < ncompute; i++) {
|
for (int i = 0; i < ncompute; i++) {
|
||||||
icompute = modify->find_compute(id_compute[i]);
|
compute[i] = modify->get_compute_by_id(id_compute[i]);
|
||||||
if (icompute < 0) error->all(FLERR, "Could not find dump custom compute ID");
|
if (!compute[i])
|
||||||
compute[i] = modify->compute[icompute];
|
error->all(FLERR, "Could not find dump custom/adios compute ID {}", id_compute[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ifix;
|
|
||||||
for (int i = 0; i < nfix; i++) {
|
for (int i = 0; i < nfix; i++) {
|
||||||
ifix = modify->find_fix(id_fix[i]);
|
fix[i] = modify->get_fix_by_id(id_fix[i]);
|
||||||
if (ifix < 0) error->all(FLERR, "Could not find dump custom fix ID");
|
if (!fix[i]) error->all(FLERR, "Could not find dump custom/adios fix ID {}", id_fix[i]);
|
||||||
fix[i] = modify->fix[ifix];
|
if (nevery % fix[i]->peratom_freq)
|
||||||
if (nevery % modify->fix[ifix]->peratom_freq)
|
error->all(FLERR, "dump custom/adios and fix {} with ID {} not computed at compatible times",
|
||||||
error->all(FLERR, "Dump custom and fix not computed at compatible times");
|
fix[i]->style, id_fix[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ivariable;
|
int ivariable;
|
||||||
for (int i = 0; i < nvariable; i++) {
|
for (int i = 0; i < nvariable; i++) {
|
||||||
ivariable = input->variable->find(id_variable[i]);
|
ivariable = input->variable->find(id_variable[i]);
|
||||||
if (ivariable < 0) error->all(FLERR, "Could not find dump custom variable name");
|
if (ivariable < 0) error->all(FLERR, "Could not find dump custom/adios variable name");
|
||||||
variable[i] = ivariable;
|
variable[i] = ivariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
if (iregion >= 0) {
|
if (idregion && !domain->get_region_by_id(idregion))
|
||||||
iregion = domain->find_region(idregion);
|
error->all(FLERR, "Region {} for dump custom/adios does not exist", idregion);
|
||||||
if (iregion == -1) error->all(FLERR, "Region ID for dump custom does not exist");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Define the group of variables for the atom style here since it's a fixed
|
/* Define the group of variables for the atom style here since it's a fixed
|
||||||
* set */
|
* set */
|
||||||
|
|||||||
@ -40,8 +40,8 @@ class ReaderADIOS : public Reader {
|
|||||||
|
|
||||||
int read_time(bigint &) override;
|
int read_time(bigint &) override;
|
||||||
void skip() override;
|
void skip() override;
|
||||||
bigint read_header(double[3][3], int &, int &, int, int, int *, char **, int, int, int &,
|
bigint read_header(double[3][3], int &, int &, int, int, int *, char **, int, int, int &, int &,
|
||||||
int &, int &, int &) override;
|
int &, int &) override;
|
||||||
void read_atoms(int, int, double **) override;
|
void read_atoms(int, int, double **) override;
|
||||||
|
|
||||||
void open_file(const std::string &) override;
|
void open_file(const std::string &) override;
|
||||||
|
|||||||
@ -29,7 +29,8 @@ using namespace LAMMPS_NS;
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
BondBPMSpring::BondBPMSpring(LAMMPS *_lmp) : BondBPM(_lmp), k(nullptr), ecrit(nullptr), gamma(nullptr)
|
BondBPMSpring::BondBPMSpring(LAMMPS *_lmp) :
|
||||||
|
BondBPM(_lmp), k(nullptr), ecrit(nullptr), gamma(nullptr)
|
||||||
{
|
{
|
||||||
partial_flag = 1;
|
partial_flag = 1;
|
||||||
smooth_flag = 1;
|
smooth_flag = 1;
|
||||||
|
|||||||
@ -101,7 +101,8 @@ class colvarproxy_lammps : public colvarproxy {
|
|||||||
void log(std::string const &message) override;
|
void log(std::string const &message) override;
|
||||||
void error(std::string const &message) override;
|
void error(std::string const &message) override;
|
||||||
|
|
||||||
cvm::rvector position_distance(cvm::atom_pos const &pos1, cvm::atom_pos const &pos2) const override;
|
cvm::rvector position_distance(cvm::atom_pos const &pos1,
|
||||||
|
cvm::atom_pos const &pos2) const override;
|
||||||
|
|
||||||
int backup_file(char const *filename) override;
|
int backup_file(char const *filename) override;
|
||||||
|
|
||||||
|
|||||||
@ -91,8 +91,10 @@ void DumpCFGGZ::write_header(bigint n)
|
|||||||
// so molecules are not split across periodic box boundaries
|
// so molecules are not split across periodic box boundaries
|
||||||
|
|
||||||
double scale = 1.0;
|
double scale = 1.0;
|
||||||
if (atom->peri_flag) scale = atom->pdscale;
|
if (atom->peri_flag)
|
||||||
else if (unwrapflag == 1) scale = UNWRAPEXPAND;
|
scale = atom->pdscale;
|
||||||
|
else if (unwrapflag == 1)
|
||||||
|
scale = UNWRAPEXPAND;
|
||||||
|
|
||||||
std::string header = fmt::format("Number of particles = {}\n", n);
|
std::string header = fmt::format("Number of particles = {}\n", n);
|
||||||
header += fmt::format("A = {:g} Angstrom (basic length-scale)\n", scale);
|
header += fmt::format("A = {:g} Angstrom (basic length-scale)\n", scale);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -16,7 +15,6 @@
|
|||||||
Contributing author: Andres Jaramillo-Botero (Caltech)
|
Contributing author: Andres Jaramillo-Botero (Caltech)
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
#include "compute_temp_region_eff.h"
|
#include "compute_temp_region_eff.h"
|
||||||
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
@ -33,16 +31,15 @@ using namespace LAMMPS_NS;
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
ComputeTempRegionEff::ComputeTempRegionEff(LAMMPS *lmp, int narg, char **arg) :
|
ComputeTempRegionEff::ComputeTempRegionEff(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Compute(lmp, narg, arg)
|
Compute(lmp, narg, arg), region(nullptr), idregion(nullptr)
|
||||||
{
|
{
|
||||||
if (!atom->electron_flag)
|
if (!atom->electron_flag)
|
||||||
error->all(FLERR, "Compute temp/region/eff requires atom style electron");
|
error->all(FLERR, "Compute temp/region/eff requires atom style electron");
|
||||||
|
|
||||||
if (narg != 4) error->all(FLERR, "Illegal compute temp/region/eff command");
|
if (narg != 4) error->all(FLERR, "Illegal compute temp/region/eff command");
|
||||||
|
|
||||||
iregion = domain->find_region(arg[3]);
|
region = domain->get_region_by_id(arg[3]);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for compute temp/region/eff does not exist", arg[3]);
|
||||||
error->all(FLERR,"Region ID for compute temp/region/eff does not exist");
|
|
||||||
idregion = utils::strdup(arg[3]);
|
idregion = utils::strdup(arg[3]);
|
||||||
|
|
||||||
scalar_flag = vector_flag = 1;
|
scalar_flag = vector_flag = 1;
|
||||||
@ -72,9 +69,8 @@ void ComputeTempRegionEff::init()
|
|||||||
{
|
{
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
|
|
||||||
iregion = domain->find_region(idregion);
|
region = domain->get_region_by_id(idregion);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for compute temp/region/eff does not exist", idregion);
|
||||||
error->all(FLERR,"Region ID for compute temp/region/eff does not exist");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -90,7 +86,7 @@ void ComputeTempRegionEff::setup()
|
|||||||
|
|
||||||
void ComputeTempRegionEff::dof_remove_pre()
|
void ComputeTempRegionEff::dof_remove_pre()
|
||||||
{
|
{
|
||||||
domain->regions[iregion]->prematch();
|
region->prematch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -98,7 +94,7 @@ void ComputeTempRegionEff::dof_remove_pre()
|
|||||||
int ComputeTempRegionEff::dof_remove(int i)
|
int ComputeTempRegionEff::dof_remove(int i)
|
||||||
{
|
{
|
||||||
double *x = atom->x[i];
|
double *x = atom->x[i];
|
||||||
if (domain->regions[iregion]->match(x[0],x[1],x[2])) return 0;
|
if (region->match(x[0], x[1], x[2])) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +114,6 @@ double ComputeTempRegionEff::compute_scalar()
|
|||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
double mefactor = domain->dimension / 4.0;
|
double mefactor = domain->dimension / 4.0;
|
||||||
|
|
||||||
Region *region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
region->prematch();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -129,8 +124,7 @@ double ComputeTempRegionEff::compute_scalar()
|
|||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2])) {
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2])) {
|
||||||
count++;
|
count++;
|
||||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) *
|
t += (v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]) * mass[type[i]];
|
||||||
mass[type[i]];
|
|
||||||
if (abs(spin[i]) == 1) {
|
if (abs(spin[i]) == 1) {
|
||||||
t += mefactor * mass[type[i]] * ervel[i] * ervel[i];
|
t += mefactor * mass[type[i]] * ervel[i] * ervel[i];
|
||||||
ecount++;
|
ecount++;
|
||||||
@ -153,8 +147,10 @@ double ComputeTempRegionEff::compute_scalar()
|
|||||||
if (abs(spin[i]) == 1) one++;
|
if (abs(spin[i]) == 1) one++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dof > 0.0) scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz);
|
if (dof > 0.0)
|
||||||
else scalar = 0.0;
|
scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz);
|
||||||
|
else
|
||||||
|
scalar = 0.0;
|
||||||
return scalar;
|
return scalar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +172,6 @@ void ComputeTempRegionEff::compute_vector()
|
|||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
double mefactor = domain->dimension / 4.0;
|
double mefactor = domain->dimension / 4.0;
|
||||||
|
|
||||||
Region *region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
region->prematch();
|
||||||
|
|
||||||
double massone, t[6];
|
double massone, t[6];
|
||||||
@ -212,7 +207,7 @@ void ComputeTempRegionEff::compute_vector()
|
|||||||
void ComputeTempRegionEff::remove_bias(int i, double *v)
|
void ComputeTempRegionEff::remove_bias(int i, double *v)
|
||||||
{
|
{
|
||||||
double *x = atom->x[i];
|
double *x = atom->x[i];
|
||||||
if (domain->regions[iregion]->match(x[0],x[1],x[2]))
|
if (region->match(x[0], x[1], x[2]))
|
||||||
vbias[0] = vbias[1] = vbias[2] = 0.0;
|
vbias[0] = vbias[1] = vbias[2] = 0.0;
|
||||||
else {
|
else {
|
||||||
vbias[0] = v[0];
|
vbias[0] = v[0];
|
||||||
@ -239,8 +234,6 @@ void ComputeTempRegionEff::remove_bias_all()
|
|||||||
memory->create(vbiasall, maxbias, 3, "temp/region:vbiasall");
|
memory->create(vbiasall, maxbias, 3, "temp/region:vbiasall");
|
||||||
}
|
}
|
||||||
|
|
||||||
Region *region = domain->regions[iregion];
|
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (region->match(x[i][0], x[i][1], x[i][2]))
|
if (region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
|
|||||||
@ -42,7 +42,7 @@ class ComputeTempRegionEff : public Compute {
|
|||||||
double memory_usage() override;
|
double memory_usage() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int iregion;
|
class Region *region;
|
||||||
char *idregion;
|
char *idregion;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -30,12 +30,10 @@
|
|||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
ComputeAveSphereAtom::ComputeAveSphereAtom(LAMMPS *lmp, int narg, char **arg) :
|
ComputeAveSphereAtom::ComputeAveSphereAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Compute(lmp, narg, arg),
|
Compute(lmp, narg, arg), result(nullptr)
|
||||||
result(nullptr)
|
|
||||||
{
|
{
|
||||||
if (narg < 3 || narg > 5) error->all(FLERR, "Illegal compute ave/sphere/atom command");
|
if (narg < 3 || narg > 5) error->all(FLERR, "Illegal compute ave/sphere/atom command");
|
||||||
|
|
||||||
@ -50,7 +48,8 @@ ComputeAveSphereAtom::ComputeAveSphereAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
cutoff = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
|
cutoff = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
|
||||||
if (cutoff <= 0.0) error->all(FLERR, "Illegal compute ave/sphere/atom command");
|
if (cutoff <= 0.0) error->all(FLERR, "Illegal compute ave/sphere/atom command");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else error->all(FLERR,"Illegal compute ave/sphere/atom command");
|
} else
|
||||||
|
error->all(FLERR, "Illegal compute ave/sphere/atom command");
|
||||||
}
|
}
|
||||||
|
|
||||||
peratom_flag = 1;
|
peratom_flag = 1;
|
||||||
@ -74,7 +73,8 @@ ComputeAveSphereAtom::~ComputeAveSphereAtom()
|
|||||||
void ComputeAveSphereAtom::init()
|
void ComputeAveSphereAtom::init()
|
||||||
{
|
{
|
||||||
if (!force->pair && cutoff == 0.0)
|
if (!force->pair && cutoff == 0.0)
|
||||||
error->all(FLERR,"Compute ave/sphere/atom requires a cutoff be specified "
|
error->all(FLERR,
|
||||||
|
"Compute ave/sphere/atom requires a cutoff be specified "
|
||||||
"or a pair style be defined");
|
"or a pair style be defined");
|
||||||
|
|
||||||
double skin = neighbor->skin;
|
double skin = neighbor->skin;
|
||||||
@ -86,15 +86,14 @@ void ComputeAveSphereAtom::init()
|
|||||||
cutghost = comm->cutghostuser;
|
cutghost = comm->cutghostuser;
|
||||||
|
|
||||||
if (cutoff > cutghost)
|
if (cutoff > cutghost)
|
||||||
error->all(FLERR,"Compute ave/sphere/atom cutoff exceeds ghost atom range - "
|
error->all(FLERR,
|
||||||
|
"Compute ave/sphere/atom cutoff exceeds ghost atom range - "
|
||||||
"use comm_modify cutoff command");
|
"use comm_modify cutoff command");
|
||||||
}
|
}
|
||||||
|
|
||||||
int cutflag = 1;
|
int cutflag = 1;
|
||||||
if (force->pair) {
|
if (force->pair) {
|
||||||
if (cutoff == 0.0) {
|
if (cutoff == 0.0) { cutoff = force->pair->cutforce; }
|
||||||
cutoff = force->pair->cutforce;
|
|
||||||
}
|
|
||||||
if (cutoff <= force->pair->cutforce + skin) cutflag = 0;
|
if (cutoff <= force->pair->cutforce + skin) cutflag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,8 +225,8 @@ void ComputeAveSphereAtom::compute_peratom()
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
int ComputeAveSphereAtom::pack_forward_comm(int n, int *list, double *buf,
|
int ComputeAveSphereAtom::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
|
||||||
int /*pbc_flag*/, int * /*pbc*/)
|
int * /*pbc*/)
|
||||||
{
|
{
|
||||||
double **v = atom->v;
|
double **v = atom->v;
|
||||||
|
|
||||||
|
|||||||
@ -12,9 +12,9 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef COMPUTE_CLASS
|
#ifdef COMPUTE_CLASS
|
||||||
|
// clang-format off
|
||||||
ComputeStyle(ave/sphere/atom,ComputeAveSphereAtom)
|
ComputeStyle(ave/sphere/atom,ComputeAveSphereAtom);
|
||||||
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifndef LMP_COMPUTE_AVE_SPHERE_ATOM_H
|
#ifndef LMP_COMPUTE_AVE_SPHERE_ATOM_H
|
||||||
@ -43,7 +43,7 @@ class ComputeAveSphereAtom : public Compute {
|
|||||||
double **result;
|
double **result;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace LAMMPS_NS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -354,7 +354,6 @@ void ComputeBornMatrix::compute_vector()
|
|||||||
if (angleflag) compute_angles();
|
if (angleflag) compute_angles();
|
||||||
if (dihedflag) compute_dihedrals();
|
if (dihedflag) compute_dihedrals();
|
||||||
|
|
||||||
|
|
||||||
// sum Born contributions over all procs
|
// sum Born contributions over all procs
|
||||||
|
|
||||||
MPI_Allreduce(values_local, values_global, nvalues, MPI_DOUBLE, MPI_SUM, world);
|
MPI_Allreduce(values_local, values_global, nvalues, MPI_DOUBLE, MPI_SUM, world);
|
||||||
@ -373,7 +372,6 @@ void ComputeBornMatrix::compute_vector()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int m = 0; m < nvalues; m++) vector[m] = values_global[m];
|
for (int m = 0; m < nvalues; m++) vector[m] = values_global[m];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -390,10 +388,8 @@ void ComputeBornMatrix::compute_pairs()
|
|||||||
|
|
||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
int nlocal = atom->nlocal;
|
|
||||||
double *special_coul = force->special_coul;
|
double *special_coul = force->special_coul;
|
||||||
double *special_lj = force->special_lj;
|
double *special_lj = force->special_lj;
|
||||||
int newton_pair = force->newton_pair;
|
|
||||||
|
|
||||||
// invoke half neighbor list (will copy or build if necessary)
|
// invoke half neighbor list (will copy or build if necessary)
|
||||||
neighbor->build_one(list);
|
neighbor->build_one(list);
|
||||||
@ -412,7 +408,6 @@ void ComputeBornMatrix::compute_pairs()
|
|||||||
|
|
||||||
int a, b, c, d;
|
int a, b, c, d;
|
||||||
double xi1, xi2, xi3;
|
double xi1, xi2, xi3;
|
||||||
double fi1, fi2, fi3;
|
|
||||||
double xj1, xj2, xj3;
|
double xj1, xj2, xj3;
|
||||||
double rij[3];
|
double rij[3];
|
||||||
double pair_pref;
|
double pair_pref;
|
||||||
@ -476,7 +471,6 @@ void ComputeBornMatrix::compute_pairs()
|
|||||||
|
|
||||||
void ComputeBornMatrix::compute_numdiff()
|
void ComputeBornMatrix::compute_numdiff()
|
||||||
{
|
{
|
||||||
double energy;
|
|
||||||
int vec_index;
|
int vec_index;
|
||||||
|
|
||||||
// grow arrays if necessary
|
// grow arrays if necessary
|
||||||
@ -498,8 +492,6 @@ void ComputeBornMatrix::compute_numdiff()
|
|||||||
// loop over 6 strain directions
|
// loop over 6 strain directions
|
||||||
// compute stress finite difference in each direction
|
// compute stress finite difference in each direction
|
||||||
|
|
||||||
int flag, allflag;
|
|
||||||
|
|
||||||
for (int idir = 0; idir < NDIR_VIRIAL; idir++) {
|
for (int idir = 0; idir < NDIR_VIRIAL; idir++) {
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
@ -528,8 +520,7 @@ void ComputeBornMatrix::compute_numdiff()
|
|||||||
// apply derivative factor
|
// apply derivative factor
|
||||||
|
|
||||||
double denominator = -0.5 / numdelta;
|
double denominator = -0.5 / numdelta;
|
||||||
for (int m = 0; m < nvalues; m++)
|
for (int m = 0; m < nvalues; m++) values_global[m] *= denominator;
|
||||||
values_global[m] *= denominator;
|
|
||||||
|
|
||||||
// recompute virial so all virial and energy contributions are as before
|
// recompute virial so all virial and energy contributions are as before
|
||||||
// also needed for virial stress addon contributions to Born matrix
|
// also needed for virial stress addon contributions to Born matrix
|
||||||
@ -633,10 +624,6 @@ void ComputeBornMatrix::update_virial()
|
|||||||
|
|
||||||
void ComputeBornMatrix::virial_addon()
|
void ComputeBornMatrix::virial_addon()
|
||||||
{
|
{
|
||||||
|
|
||||||
int kd, nd, id, jd;
|
|
||||||
int m;
|
|
||||||
|
|
||||||
double *sigv = compute_virial->vector;
|
double *sigv = compute_virial->vector;
|
||||||
|
|
||||||
// This way of doing is not very elegant but is correct.
|
// This way of doing is not very elegant but is correct.
|
||||||
@ -678,7 +665,6 @@ void ComputeBornMatrix::virial_addon()
|
|||||||
values_global[18] += 0.5 * sigv[3];
|
values_global[18] += 0.5 * sigv[3];
|
||||||
values_global[19] += 0.5 * sigv[4];
|
values_global[19] += 0.5 * sigv[4];
|
||||||
values_global[20] += 0.5 * sigv[5];
|
values_global[20] += 0.5 * sigv[5];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -727,13 +713,11 @@ double ComputeBornMatrix::memory_usage()
|
|||||||
|
|
||||||
void ComputeBornMatrix::compute_bonds()
|
void ComputeBornMatrix::compute_bonds()
|
||||||
{
|
{
|
||||||
int i, m, n, nb, atom1, atom2, imol, iatom, btype, ivar;
|
int i, m, nb, atom1, atom2, imol, iatom, btype;
|
||||||
tagint tagprev;
|
tagint tagprev;
|
||||||
double dx, dy, dz, rsq;
|
double dx, dy, dz, rsq;
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **v = atom->v;
|
|
||||||
int *type = atom->type;
|
|
||||||
tagint *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
int *num_bond = atom->num_bond;
|
int *num_bond = atom->num_bond;
|
||||||
tagint **bond_atom = atom->bond_atom;
|
tagint **bond_atom = atom->bond_atom;
|
||||||
@ -821,13 +805,12 @@ void ComputeBornMatrix::compute_bonds()
|
|||||||
|
|
||||||
void ComputeBornMatrix::compute_angles()
|
void ComputeBornMatrix::compute_angles()
|
||||||
{
|
{
|
||||||
int i, m, n, na, atom1, atom2, atom3, imol, iatom, atype, ivar;
|
int i, m, na, atom1, atom2, atom3, imol, iatom, atype;
|
||||||
tagint tagprev;
|
tagint tagprev;
|
||||||
double delx1, dely1, delz1, delx2, dely2, delz2;
|
double delx1, dely1, delz1, delx2, dely2, delz2;
|
||||||
double rsq1, rsq2, r1, r2, cost;
|
double rsq1, rsq2, r1, r2, cost;
|
||||||
double r1r2, r1r2inv;
|
double r1r2, r1r2inv;
|
||||||
double rsq1inv, rsq2inv, cinv;
|
double rsq1inv, rsq2inv, cinv;
|
||||||
double *ptr;
|
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
tagint *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
@ -986,12 +969,11 @@ void ComputeBornMatrix::compute_angles()
|
|||||||
|
|
||||||
void ComputeBornMatrix::compute_dihedrals()
|
void ComputeBornMatrix::compute_dihedrals()
|
||||||
{
|
{
|
||||||
int i, m, n, nd, atom1, atom2, atom3, atom4, imol, iatom, dtype, ivar;
|
int i, m, nd, atom1, atom2, atom3, atom4, imol, iatom;
|
||||||
tagint tagprev;
|
tagint tagprev;
|
||||||
double vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z, vb2xm, vb2ym, vb2zm;
|
double vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z;
|
||||||
double ax, ay, az, bx, by, bz, rasq, rbsq, dotab, rgsq, rg, ra2inv, rb2inv, dotabinv, rabinv;
|
double ax, ay, az, bx, by, bz, rasq, rbsq, dotab, ra2inv, rb2inv, dotabinv, rabinv;
|
||||||
double si, co, phi;
|
double co;
|
||||||
double *ptr;
|
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
tagint *tag = atom->tag;
|
tagint *tag = atom->tag;
|
||||||
@ -1013,28 +995,15 @@ void ComputeBornMatrix::compute_dihedrals()
|
|||||||
|
|
||||||
Dihedral *dihedral = force->dihedral;
|
Dihedral *dihedral = force->dihedral;
|
||||||
|
|
||||||
double dudih, du2dih;
|
|
||||||
int al, be, mu, nu, e, f;
|
int al, be, mu, nu, e, f;
|
||||||
double b1sq;
|
double dudih, du2dih, b1sq, b2sq, b3sq, b1b2, b1b3, b2b3;
|
||||||
double b2sq;
|
double b1[3], b2[3], b3[3];
|
||||||
double b3sq;
|
|
||||||
double b1b2;
|
|
||||||
double b1b3;
|
|
||||||
double b2b3;
|
|
||||||
double b1[3];
|
|
||||||
double b2[3];
|
|
||||||
double b3[3];
|
|
||||||
|
|
||||||
// 1st and 2nd order derivatives of the dot products
|
// 1st and 2nd order derivatives of the dot products
|
||||||
double dab[6];
|
double dab[6], daa[6], dbb[6];
|
||||||
double daa[6];
|
double d2ab, d2aa, d2bb;
|
||||||
double dbb[6];
|
|
||||||
double d2ab;
|
|
||||||
double d2aa;
|
|
||||||
double d2bb;
|
|
||||||
|
|
||||||
double dcos[6];
|
double dcos[6], d2cos;
|
||||||
double d2cos;
|
|
||||||
|
|
||||||
for (i = 0; i < 6; i++) dab[i] = daa[i] = dbb[i] = dcos[i] = 0;
|
for (i = 0; i < 6; i++) dab[i] = daa[i] = dbb[i] = dcos[i] = 0;
|
||||||
|
|
||||||
@ -1043,7 +1012,8 @@ void ComputeBornMatrix::compute_dihedrals()
|
|||||||
|
|
||||||
// if (molecular == 1)
|
// if (molecular == 1)
|
||||||
// nd = num_dihedral[atom2];
|
// nd = num_dihedral[atom2];
|
||||||
if (molecular == Atom::MOLECULAR) nd = num_dihedral[atom2];
|
if (molecular == Atom::MOLECULAR)
|
||||||
|
nd = num_dihedral[atom2];
|
||||||
else {
|
else {
|
||||||
if (molindex[atom2] < 0) continue;
|
if (molindex[atom2] < 0) continue;
|
||||||
imol = molindex[atom2];
|
imol = molindex[atom2];
|
||||||
@ -1120,9 +1090,7 @@ void ComputeBornMatrix::compute_dihedrals()
|
|||||||
|
|
||||||
rasq = ax * ax + ay * ay + az * az;
|
rasq = ax * ax + ay * ay + az * az;
|
||||||
rbsq = bx * bx + by * by + bz * bz;
|
rbsq = bx * bx + by * by + bz * bz;
|
||||||
rgsq = vb2x * vb2x + vb2y * vb2y + vb2z * vb2z;
|
|
||||||
dotab = ax * bx + ay * by + az * bz;
|
dotab = ax * bx + ay * by + az * bz;
|
||||||
rg = sqrt(rgsq);
|
|
||||||
|
|
||||||
ra2inv = rb2inv = rabinv = dotabinv = 0.0;
|
ra2inv = rb2inv = rabinv = dotabinv = 0.0;
|
||||||
if (rasq > 0) ra2inv = 1.0 / rasq;
|
if (rasq > 0) ra2inv = 1.0 / rasq;
|
||||||
@ -1131,9 +1099,8 @@ void ComputeBornMatrix::compute_dihedrals()
|
|||||||
rabinv = sqrt(ra2inv * rb2inv);
|
rabinv = sqrt(ra2inv * rb2inv);
|
||||||
|
|
||||||
co = (ax * bx + ay * by + az * bz) * rabinv;
|
co = (ax * bx + ay * by + az * bz) * rabinv;
|
||||||
si = sqrt(b2sq) * rabinv * (ax * vb3x + ay * vb3y + az * vb3z);
|
|
||||||
|
|
||||||
if (co == 0.) {
|
if (co == 0.0) {
|
||||||
// Worst case scenario. A 0 cosine has an undefined logarithm.
|
// Worst case scenario. A 0 cosine has an undefined logarithm.
|
||||||
// We then add a small amount of the third bond to the first one
|
// We then add a small amount of the third bond to the first one
|
||||||
// so they are not orthogonal anymore and recompute.
|
// so they are not orthogonal anymore and recompute.
|
||||||
@ -1160,13 +1127,10 @@ void ComputeBornMatrix::compute_dihedrals()
|
|||||||
if (dotab != 0.) dotabinv = 1.0 / dotab;
|
if (dotab != 0.) dotabinv = 1.0 / dotab;
|
||||||
rabinv = sqrt(ra2inv * rb2inv);
|
rabinv = sqrt(ra2inv * rb2inv);
|
||||||
co = (ax * bx + ay * by + az * bz) * rabinv;
|
co = (ax * bx + ay * by + az * bz) * rabinv;
|
||||||
si = sqrt(b2sq) * rabinv * (ax * vb3x + ay * vb3y + az * vb3z);
|
|
||||||
}
|
}
|
||||||
if (co > 1.0) co = 1.0;
|
if (co > 1.0) co = 1.0;
|
||||||
if (co < -1.0) co = -1.0;
|
if (co < -1.0) co = -1.0;
|
||||||
|
|
||||||
phi = atan2(si, co);
|
|
||||||
|
|
||||||
al = be = mu = nu = e = f = 0;
|
al = be = mu = nu = e = f = 0;
|
||||||
// clang-format off
|
// clang-format off
|
||||||
for (m = 0; m<6; m++) {
|
for (m = 0; m<6; m++) {
|
||||||
|
|||||||
@ -452,7 +452,8 @@ void ComputeStressCartesian::compute_pressure_1d(double fpair, double xi, double
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ComputeStressCartesian::compute_pressure_2d(double fpair, double xi, double yi, double /*xj*/,
|
void ComputeStressCartesian::compute_pressure_2d(double fpair, double xi, double yi, double /*xj*/,
|
||||||
double /*yj*/, double delx, double dely, double delz)
|
double /*yj*/, double delx, double dely,
|
||||||
|
double delz)
|
||||||
{
|
{
|
||||||
int bin1, bin2, next_bin1, next_bin2;
|
int bin1, bin2, next_bin1, next_bin2;
|
||||||
double la = 0.0, lb = 0.0, l_sum = 0.0;
|
double la = 0.0, lb = 0.0, l_sum = 0.0;
|
||||||
|
|||||||
@ -59,8 +59,8 @@ extern "C" {
|
|||||||
|
|
||||||
typedef int bool_t;
|
typedef int bool_t;
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__APPLE__) || defined(__FreeBSD__) || \
|
#if defined(_WIN32) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || \
|
||||||
defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
typedef char *caddr_t;
|
typedef char *caddr_t;
|
||||||
typedef unsigned int u_int;
|
typedef unsigned int u_int;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -39,62 +38,52 @@
|
|||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
|
||||||
#define MAXLINE 1024
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixElectronStopping::FixElectronStopping(LAMMPS *lmp, int narg, char **arg) :
|
FixElectronStopping::FixElectronStopping(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg)
|
Fix(lmp, narg, arg), elstop_ranges(nullptr), idregion(nullptr), region(nullptr), list(nullptr)
|
||||||
{
|
{
|
||||||
scalar_flag = 1; // Has compute_scalar
|
scalar_flag = 1; // Has compute_scalar
|
||||||
global_freq = 1; // SeLoss computed every step
|
global_freq = 1; // SeLoss computed every step
|
||||||
extscalar = 0; // SeLoss compute_scalar is intensive
|
extscalar = 0; // SeLoss compute_scalar is intensive
|
||||||
nevery = 1; // Run fix every step
|
nevery = 1; // Run fix every step
|
||||||
|
|
||||||
|
|
||||||
// args: 0 = fix ID, 1 = group ID, 2 = "electron/stopping"
|
// args: 0 = fix ID, 1 = group ID, 2 = "electron/stopping"
|
||||||
// 3 = Ecut, 4 = file path
|
// 3 = Ecut, 4 = file path
|
||||||
// optional rest: "region" <region name>
|
// optional rest: "region" <region name>
|
||||||
// "minneigh" <min number of neighbors>
|
// "minneigh" <min number of neighbors>
|
||||||
|
|
||||||
if (narg < 5) error->all(FLERR,
|
if (narg < 5) error->all(FLERR, "Illegal fix electron/stopping command: too few arguments");
|
||||||
"Illegal fix electron/stopping command: too few arguments");
|
|
||||||
|
|
||||||
Ecut = utils::numeric(FLERR, arg[3], false, lmp);
|
Ecut = utils::numeric(FLERR, arg[3], false, lmp);
|
||||||
if (Ecut <= 0.0) error->all(FLERR,
|
if (Ecut <= 0.0) error->all(FLERR, "Illegal fix electron/stopping command: Ecut <= 0");
|
||||||
"Illegal fix electron/stopping command: Ecut <= 0");
|
|
||||||
|
|
||||||
int iarg = 5;
|
int iarg = 5;
|
||||||
iregion = -1;
|
|
||||||
minneigh = 1;
|
minneigh = 1;
|
||||||
bool minneighflag = false;
|
bool minneighflag = false;
|
||||||
|
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg], "region") == 0) {
|
if (strcmp(arg[iarg], "region") == 0) {
|
||||||
if (iregion >= 0) error->all(FLERR,
|
if (region) error->all(FLERR, "Illegal fix electron/stopping command: region given twice");
|
||||||
"Illegal fix electron/stopping command: region given twice");
|
if (iarg + 2 > narg)
|
||||||
if (iarg+2 > narg) error->all(FLERR,
|
error->all(FLERR, "Illegal fix electron/stopping command: region name missing");
|
||||||
"Illegal fix electron/stopping command: region name missing");
|
region = domain->get_region_by_id(arg[iarg + 1]);
|
||||||
iregion = domain->find_region(arg[iarg+1]);
|
if (!region)
|
||||||
if (iregion < 0) error->all(FLERR,
|
error->all(FLERR, "Region {} for fix electron/stopping does not exist", arg[iarg + 1]);
|
||||||
"Region ID for fix electron/stopping does not exist");
|
idregion = utils::strdup(arg[iarg + 1]);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
}
|
} else if (strcmp(arg[iarg], "minneigh") == 0) {
|
||||||
else if (strcmp(arg[iarg], "minneigh") == 0) {
|
if (minneighflag)
|
||||||
if (minneighflag) error->all(FLERR,
|
error->all(FLERR, "Illegal fix electron/stopping command: minneigh given twice");
|
||||||
"Illegal fix electron/stopping command: minneigh given twice");
|
|
||||||
minneighflag = true;
|
minneighflag = true;
|
||||||
if (iarg+2 > narg) error->all(FLERR,
|
if (iarg + 2 > narg)
|
||||||
"Illegal fix electron/stopping command: minneigh number missing");
|
error->all(FLERR, "Illegal fix electron/stopping command: minneigh number missing");
|
||||||
minneigh = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
|
minneigh = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
|
||||||
if (minneigh < 0) error->all(FLERR,
|
if (minneigh < 0) error->all(FLERR, "Illegal fix electron/stopping command: minneigh < 0");
|
||||||
"Illegal fix electron/stopping command: minneigh < 0");
|
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
} else
|
||||||
|
error->all(FLERR, "Illegal fix electron/stopping command: unknown argument");
|
||||||
}
|
}
|
||||||
else error->all(FLERR,
|
|
||||||
"Illegal fix electron/stopping command: unknown argument");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Read the input file for energy ranges and stopping powers.
|
// Read the input file for energy ranges and stopping powers.
|
||||||
// First proc 0 reads the file, then bcast to others.
|
// First proc 0 reads the file, then bcast to others.
|
||||||
@ -108,8 +97,7 @@ FixElectronStopping::FixElectronStopping(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
MPI_Bcast(&maxlines, 1, MPI_INT, 0, world);
|
MPI_Bcast(&maxlines, 1, MPI_INT, 0, world);
|
||||||
MPI_Bcast(&table_entries, 1, MPI_INT, 0, world);
|
MPI_Bcast(&table_entries, 1, MPI_INT, 0, world);
|
||||||
|
|
||||||
if (comm->me != 0)
|
if (comm->me != 0) memory->create(elstop_ranges, ncol, maxlines, "electron/stopping:table");
|
||||||
memory->create(elstop_ranges, ncol, maxlines, "electron/stopping:table");
|
|
||||||
|
|
||||||
MPI_Bcast(&elstop_ranges[0][0], ncol * maxlines, MPI_DOUBLE, 0, world);
|
MPI_Bcast(&elstop_ranges[0][0], ncol * maxlines, MPI_DOUBLE, 0, world);
|
||||||
}
|
}
|
||||||
@ -136,6 +124,10 @@ void FixElectronStopping::init()
|
|||||||
{
|
{
|
||||||
SeLoss_sync_flag = 0;
|
SeLoss_sync_flag = 0;
|
||||||
SeLoss = 0.0;
|
SeLoss = 0.0;
|
||||||
|
if (idregion) {
|
||||||
|
region = domain->get_region_by_id(idregion);
|
||||||
|
if (!region) error->all(FLERR, "Region {} for fix electron/stopping does not exist", idregion);
|
||||||
|
}
|
||||||
|
|
||||||
// need an occasional full neighbor list
|
// need an occasional full neighbor list
|
||||||
neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL);
|
neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL);
|
||||||
@ -181,13 +173,12 @@ void FixElectronStopping::post_force(int /*vflag*/)
|
|||||||
|
|
||||||
if (energy < Ecut) continue;
|
if (energy < Ecut) continue;
|
||||||
if (energy < elstop_ranges[0][0]) continue;
|
if (energy < elstop_ranges[0][0]) continue;
|
||||||
if (energy > elstop_ranges[0][table_entries - 1]) error->one(FLERR,
|
if (energy > elstop_ranges[0][table_entries - 1])
|
||||||
"Atom kinetic energy too high for fix electron/stopping");
|
error->one(FLERR, "Atom kinetic energy too high for fix electron/stopping");
|
||||||
|
|
||||||
if (iregion >= 0) {
|
if (region) {
|
||||||
// Only apply in the given region
|
// Only apply in the given region
|
||||||
if (domain->regions[iregion]->match(x[i][0], x[i][1], x[i][2]) != 1)
|
if (region->match(x[i][0], x[i][1], x[i][2]) != 1) continue;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Binary search to find correct energy range
|
// Binary search to find correct energy range
|
||||||
@ -196,8 +187,10 @@ void FixElectronStopping::post_force(int /*vflag*/)
|
|||||||
while (true) {
|
while (true) {
|
||||||
int ihalf = idown + (iup - idown) / 2;
|
int ihalf = idown + (iup - idown) / 2;
|
||||||
if (ihalf == idown) break;
|
if (ihalf == idown) break;
|
||||||
if (elstop_ranges[0][ihalf] < energy) idown = ihalf;
|
if (elstop_ranges[0][ihalf] < energy)
|
||||||
else iup = ihalf;
|
idown = ihalf;
|
||||||
|
else
|
||||||
|
iup = ihalf;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Se_lo = elstop_ranges[itype][idown];
|
double Se_lo = elstop_ranges[itype][idown];
|
||||||
@ -257,16 +250,14 @@ void FixElectronStopping::read_table(const char *file)
|
|||||||
throw TokenizerException("energy values must be positive and in ascending order", line);
|
throw TokenizerException("energy values must be positive and in ascending order", line);
|
||||||
|
|
||||||
oldvalue = elstop_ranges[0][nlines];
|
oldvalue = elstop_ranges[0][nlines];
|
||||||
for (int i = 1; i < ncol; ++i)
|
for (int i = 1; i < ncol; ++i) elstop_ranges[i][nlines] = values.next_double();
|
||||||
elstop_ranges[i][nlines] = values.next_double();
|
|
||||||
|
|
||||||
++nlines;
|
++nlines;
|
||||||
}
|
}
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
error->one(FLERR, "Problem parsing electron stopping data: {}", e.what());
|
error->one(FLERR, "Problem parsing electron stopping data: {}", e.what());
|
||||||
}
|
}
|
||||||
if (nlines == 0)
|
if (nlines == 0) error->one(FLERR, "Did not find any data in electron/stopping table file");
|
||||||
error->one(FLERR, "Did not find any data in electron/stopping table file");
|
|
||||||
|
|
||||||
table_entries = nlines;
|
table_entries = nlines;
|
||||||
}
|
}
|
||||||
@ -281,8 +272,7 @@ void FixElectronStopping::grow_table()
|
|||||||
double **new_array;
|
double **new_array;
|
||||||
memory->create(new_array, ncol, new_maxlines, "electron/stopping:table");
|
memory->create(new_array, ncol, new_maxlines, "electron/stopping:table");
|
||||||
|
|
||||||
for (int i = 0; i < ncol; i++)
|
for (int i = 0; i < ncol; i++) memcpy(new_array[i], elstop_ranges[i], maxlines * sizeof(double));
|
||||||
memcpy(new_array[i], elstop_ranges[i], maxlines*sizeof(double));
|
|
||||||
|
|
||||||
memory->destroy(elstop_ranges);
|
memory->destroy(elstop_ranges);
|
||||||
elstop_ranges = new_array;
|
elstop_ranges = new_array;
|
||||||
|
|||||||
@ -52,7 +52,8 @@ class FixElectronStopping : public Fix {
|
|||||||
double **elstop_ranges; // [ 0][i]: energies
|
double **elstop_ranges; // [ 0][i]: energies
|
||||||
// [>0][i]: stopping powers per type
|
// [>0][i]: stopping powers per type
|
||||||
|
|
||||||
int iregion; // region index if used, else -1
|
char *idregion; // region id
|
||||||
|
class Region *region; // region pointer if used, else NULL
|
||||||
int minneigh; // minimum number of neighbors
|
int minneigh; // minimum number of neighbors
|
||||||
|
|
||||||
class NeighList *list;
|
class NeighList *list;
|
||||||
|
|||||||
@ -41,7 +41,8 @@ using namespace FixConst;
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixNumDiff::FixNumDiff(LAMMPS *lmp, int narg, char **arg) :
|
FixNumDiff::FixNumDiff(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg), id_pe(nullptr), pe(nullptr), numdiff_forces(nullptr), temp_x(nullptr), temp_f(nullptr)
|
Fix(lmp, narg, arg), id_pe(nullptr), pe(nullptr), numdiff_forces(nullptr), temp_x(nullptr),
|
||||||
|
temp_f(nullptr)
|
||||||
{
|
{
|
||||||
if (narg < 5) error->all(FLERR, "Illegal fix numdiff command");
|
if (narg < 5) error->all(FLERR, "Illegal fix numdiff command");
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -32,18 +31,19 @@ enum{NONE=-1,X=0,Y=1,Z=2,XYZMASK=3,MINUS=4,PLUS=0};
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixOneWay::FixOneWay(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
FixOneWay::FixOneWay(LAMMPS *lmp, int narg, char **arg) :
|
||||||
|
Fix(lmp, narg, arg), region(nullptr), idregion(nullptr)
|
||||||
{
|
{
|
||||||
direction = NONE;
|
direction = NONE;
|
||||||
regionidx = 0;
|
|
||||||
regionstr = nullptr;
|
|
||||||
|
|
||||||
if (narg < 6) error->all(FLERR, "Illegal fix oneway command");
|
if (narg < 6) error->all(FLERR, "Illegal fix oneway command");
|
||||||
|
|
||||||
nevery = utils::inumeric(FLERR, arg[3], false, lmp);
|
nevery = utils::inumeric(FLERR, arg[3], false, lmp);
|
||||||
if (nevery < 1) error->all(FLERR, "Illegal fix oneway command");
|
if (nevery < 1) error->all(FLERR, "Illegal fix oneway command");
|
||||||
|
|
||||||
regionstr = utils::strdup(arg[4]);
|
idregion = utils::strdup(arg[4]);
|
||||||
|
if (!domain->get_region_by_id(idregion))
|
||||||
|
error->all(FLERR, "Region {} for fix oneway does not exist", idregion);
|
||||||
|
|
||||||
if (strcmp(arg[5], "x") == 0) direction = X | PLUS;
|
if (strcmp(arg[5], "x") == 0) direction = X | PLUS;
|
||||||
if (strcmp(arg[5], "X") == 0) direction = X | PLUS;
|
if (strcmp(arg[5], "X") == 0) direction = X | PLUS;
|
||||||
@ -65,7 +65,7 @@ FixOneWay::FixOneWay(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
|||||||
|
|
||||||
FixOneWay::~FixOneWay()
|
FixOneWay::~FixOneWay()
|
||||||
{
|
{
|
||||||
delete[] regionstr;
|
delete[] idregion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -79,16 +79,14 @@ int FixOneWay::setmask()
|
|||||||
|
|
||||||
void FixOneWay::init()
|
void FixOneWay::init()
|
||||||
{
|
{
|
||||||
regionidx = domain->find_region(regionstr);
|
region = domain->get_region_by_id(idregion);
|
||||||
if (regionidx < 0)
|
if (!region) error->all(FLERR, "Region {} for fix oneway does not exist", idregion);
|
||||||
error->all(FLERR,"Region for fix oneway does not exist");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixOneWay::end_of_step()
|
void FixOneWay::end_of_step()
|
||||||
{
|
{
|
||||||
Region *region = domain->regions[regionidx];
|
|
||||||
region->prematch();
|
region->prematch();
|
||||||
|
|
||||||
const int idx = direction & XYZMASK;
|
const int idx = direction & XYZMASK;
|
||||||
@ -107,4 +105,3 @@ void FixOneWay::end_of_step()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,8 +34,8 @@ class FixOneWay : public Fix {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
int direction;
|
int direction;
|
||||||
int regionidx;
|
class Region *region;
|
||||||
char *regionstr;
|
char *idregion;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LAMMPS_NS
|
} // namespace LAMMPS_NS
|
||||||
|
|||||||
@ -308,8 +308,8 @@ void FixTTMGrid::read_electron_temperatures(const std::string &filename)
|
|||||||
if (ix < 0 || ix >= nxgrid || iy < 0 || iy >= nygrid || iz < 0 || iz >= nzgrid)
|
if (ix < 0 || ix >= nxgrid || iy < 0 || iy >= nygrid || iz < 0 || iz >= nzgrid)
|
||||||
throw TokenizerException("Fix ttm/grid invalid grid index in input", "");
|
throw TokenizerException("Fix ttm/grid invalid grid index in input", "");
|
||||||
|
|
||||||
if (ix >= nxlo_in && ix <= nxhi_in && iy >= nylo_in && iy <= nyhi_in
|
if (ix >= nxlo_in && ix <= nxhi_in && iy >= nylo_in && iy <= nyhi_in && iz >= nzlo_in &&
|
||||||
&& iz >= nzlo_in && iz <= nzhi_in) {
|
iz <= nzhi_in) {
|
||||||
T_electron[iz][iy][ix] = values.next_double();
|
T_electron[iz][iy][ix] = values.next_double();
|
||||||
T_initial_set[iz][iy][ix] = 1;
|
T_initial_set[iz][iy][ix] = 1;
|
||||||
}
|
}
|
||||||
@ -356,9 +356,11 @@ void FixTTMGrid::write_electron_temperatures(const std::string &filename)
|
|||||||
FPout = fopen(filename.c_str(), "w");
|
FPout = fopen(filename.c_str(), "w");
|
||||||
if (!FPout) error->one(FLERR, "Fix ttm/grid could not open output file");
|
if (!FPout) error->one(FLERR, "Fix ttm/grid could not open output file");
|
||||||
|
|
||||||
fmt::print(FPout,"# DATE: {} UNITS: {} COMMENT: Electron temperature "
|
fmt::print(FPout,
|
||||||
"{}x{}x{} grid at step {}. Created by fix {}\n", utils::current_date(),
|
"# DATE: {} UNITS: {} COMMENT: Electron temperature "
|
||||||
update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep, style);
|
"{}x{}x{} grid at step {}. Created by fix {}\n",
|
||||||
|
utils::current_date(), update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep,
|
||||||
|
style);
|
||||||
}
|
}
|
||||||
|
|
||||||
gc->gather(GridComm::FIX, this, 1, sizeof(double), 1, nullptr, MPI_DOUBLE);
|
gc->gather(GridComm::FIX, this, 1, sizeof(double), 1, nullptr, MPI_DOUBLE);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -23,6 +22,7 @@
|
|||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "math_extra.h"
|
#include "math_extra.h"
|
||||||
|
#include "math_special.h"
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
#include "respa.h"
|
#include "respa.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
@ -31,11 +31,12 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
using MathSpecial::powint;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixWallRegionEES::FixWallRegionEES(LAMMPS *lmp, int narg, char **arg) :
|
FixWallRegionEES::FixWallRegionEES(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg)
|
Fix(lmp, narg, arg), idregion(nullptr), region(nullptr)
|
||||||
{
|
{
|
||||||
if (narg != 7) error->all(FLERR, "Illegal fix wall/region/ees command");
|
if (narg != 7) error->all(FLERR, "Illegal fix wall/region/ees command");
|
||||||
|
|
||||||
@ -49,9 +50,8 @@ FixWallRegionEES::FixWallRegionEES(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
// parse args
|
// parse args
|
||||||
|
|
||||||
iregion = domain->find_region(arg[3]);
|
region = domain->get_region_by_id(arg[3]);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for fix wall/region/ees does not exist", arg[3]);
|
||||||
error->all(FLERR,"Region ID for fix wall/region/ees does not exist");
|
|
||||||
idregion = utils::strdup(arg[3]);
|
idregion = utils::strdup(arg[3]);
|
||||||
epsilon = utils::numeric(FLERR, arg[4], false, lmp);
|
epsilon = utils::numeric(FLERR, arg[4], false, lmp);
|
||||||
sigma = utils::numeric(FLERR, arg[5], false, lmp);
|
sigma = utils::numeric(FLERR, arg[5], false, lmp);
|
||||||
@ -87,13 +87,11 @@ void FixWallRegionEES::init()
|
|||||||
{
|
{
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
|
|
||||||
iregion = domain->find_region(idregion);
|
region = domain->get_region_by_id(idregion);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for fix wall/region/ees does not exist", idregion);
|
||||||
error->all(FLERR,"Region ID for fix wall/region/ees does not exist");
|
|
||||||
|
|
||||||
avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
|
avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
|
||||||
if (!avec)
|
if (!avec) error->all(FLERR, "Fix wall/region/ees requires atom style ellipsoid");
|
||||||
error->all(FLERR,"Fix wall/region/ees requires atom style ellipsoid");
|
|
||||||
|
|
||||||
// check that all particles are finite-size ellipsoids
|
// check that all particles are finite-size ellipsoids
|
||||||
// no point particles allowed, spherical is OK
|
// no point particles allowed, spherical is OK
|
||||||
@ -105,19 +103,18 @@ void FixWallRegionEES::init()
|
|||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit)
|
if (mask[i] & groupbit)
|
||||||
if (ellipsoid[i] < 0)
|
if (ellipsoid[i] < 0)
|
||||||
error->one(FLERR,"Fix wall/region/ees requires extended particles");
|
error->one(FLERR, "Fix wall/region/ees requires only extended particles");
|
||||||
|
|
||||||
// setup coefficients
|
// setup coefficients
|
||||||
|
|
||||||
coeff1 = ( 2. / 4725. ) * epsilon * pow(sigma,12.0);
|
coeff1 = (2.0 / 4725.0) * epsilon * powint(sigma, 12);
|
||||||
coeff2 = ( 1. / 24. ) * epsilon * pow(sigma,6.0);
|
coeff2 = (1.0 / 24.0) * epsilon * powint(sigma, 6);
|
||||||
coeff3 = ( 2. / 315. ) * epsilon * pow(sigma,12.0);
|
coeff3 = (2.0 / 315.0) * epsilon * powint(sigma, 12);
|
||||||
coeff4 = ( 1. / 3. ) * epsilon * pow(sigma,6.0);
|
coeff4 = (1.0 / 3.0) * epsilon * powint(sigma, 6);
|
||||||
coeff5 = ( 4. / 315. ) * epsilon * pow(sigma,12.0);
|
coeff5 = (4.0 / 315.0) * epsilon * powint(sigma, 12);
|
||||||
coeff6 = ( 1. / 12. ) * epsilon * pow(sigma,6.0);
|
coeff6 = (1.0 / 12.0) * epsilon * powint(sigma, 6);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
|
|
||||||
if (utils::strmatch(update->integrate_style, "^respa"))
|
if (utils::strmatch(update->integrate_style, "^respa"))
|
||||||
nlevels_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels;
|
nlevels_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels;
|
||||||
}
|
}
|
||||||
@ -126,12 +123,13 @@ void FixWallRegionEES::init()
|
|||||||
|
|
||||||
void FixWallRegionEES::setup(int vflag)
|
void FixWallRegionEES::setup(int vflag)
|
||||||
{
|
{
|
||||||
if (utils::strmatch(update->integrate_style,"^verlet"))
|
if (utils::strmatch(update->integrate_style, "^respa")) {
|
||||||
post_force(vflag);
|
auto respa = dynamic_cast<Respa *>(update->integrate);
|
||||||
else {
|
respa->copy_flevel_f(nlevels_respa - 1);
|
||||||
(dynamic_cast<Respa *>( update->integrate))->copy_flevel_f(nlevels_respa-1);
|
|
||||||
post_force_respa(vflag, nlevels_respa - 1, 0);
|
post_force_respa(vflag, nlevels_respa - 1, 0);
|
||||||
(dynamic_cast<Respa *>( update->integrate))->copy_f_flevel(nlevels_respa-1);
|
respa->copy_f_flevel(nlevels_respa - 1);
|
||||||
|
} else {
|
||||||
|
post_force(vflag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +163,6 @@ void FixWallRegionEES::post_force(int /*vflag*/)
|
|||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
Region *region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
region->prematch();
|
||||||
|
|
||||||
int onflag = 0;
|
int onflag = 0;
|
||||||
@ -185,7 +182,8 @@ void FixWallRegionEES::post_force(int /*vflag*/)
|
|||||||
double tempvec[3] = {0, 0, 0};
|
double tempvec[3] = {0, 0, 0};
|
||||||
double sn2 = 0.0;
|
double sn2 = 0.0;
|
||||||
double nhat[3] = {0, 0, 0};
|
double nhat[3] = {0, 0, 0};
|
||||||
double* shape = bonus[ellipsoid[i]].shape;;
|
double *shape = bonus[ellipsoid[i]].shape;
|
||||||
|
;
|
||||||
MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat, A);
|
MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat, A);
|
||||||
|
|
||||||
for (int which = 0; which < 3; which++) { //me
|
for (int which = 0; which < 3; which++) { //me
|
||||||
@ -215,7 +213,8 @@ void FixWallRegionEES::post_force(int /*vflag*/)
|
|||||||
} else if (region->contact[m].delz != 0 && region->contact[m].r <= tooclose[2]) {
|
} else if (region->contact[m].delz != 0 && region->contact[m].r <= tooclose[2]) {
|
||||||
onflag = 1;
|
onflag = 1;
|
||||||
continue;
|
continue;
|
||||||
} else rinv = 1.0/region->contact[m].r;
|
} else
|
||||||
|
rinv = 1.0 / region->contact[m].r;
|
||||||
|
|
||||||
ees(m, i);
|
ees(m, i);
|
||||||
|
|
||||||
@ -237,8 +236,8 @@ void FixWallRegionEES::post_force(int /*vflag*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onflag) error->one(FLERR,"Particle on or inside surface of region "
|
if (onflag)
|
||||||
"used in fix wall/region/ees");
|
error->one(FLERR, "Particle on or inside surface of region used in fix wall/region/ees");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -292,7 +291,6 @@ double FixWallRegionEES::compute_vector(int n)
|
|||||||
|
|
||||||
void FixWallRegionEES::ees(int m, int i)
|
void FixWallRegionEES::ees(int m, int i)
|
||||||
{
|
{
|
||||||
Region *region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
region->prematch();
|
||||||
|
|
||||||
double delta, delta2, delta3, delta4, delta5, delta6;
|
double delta, delta2, delta3, delta4, delta5, delta6;
|
||||||
@ -318,7 +316,8 @@ void FixWallRegionEES::ees(int m, int i)
|
|||||||
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
|
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
|
||||||
int *ellipsoid = atom->ellipsoid;
|
int *ellipsoid = atom->ellipsoid;
|
||||||
|
|
||||||
double* shape = bonus[ellipsoid[i]].shape;;
|
double *shape = bonus[ellipsoid[i]].shape;
|
||||||
|
;
|
||||||
MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat, A);
|
MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat, A);
|
||||||
|
|
||||||
sigman2 = 0.0;
|
sigman2 = 0.0;
|
||||||
@ -352,15 +351,16 @@ void FixWallRegionEES::ees(int m, int i)
|
|||||||
hps = delta + sigman;
|
hps = delta + sigman;
|
||||||
hms = delta - sigman;
|
hms = delta - sigman;
|
||||||
|
|
||||||
fwall = -1*coeff4/hhss2 + coeff3
|
fwall = -1 * coeff4 / hhss2 +
|
||||||
* (21*delta6 + 63*delta4*sigman2 + 27*delta2*sigman4 + sigman6) / hhss8;
|
coeff3 * (21 * delta6 + 63 * delta4 * sigman2 + 27 * delta2 * sigman4 + sigman6) / hhss8;
|
||||||
|
|
||||||
eng = -1 * coeff2 * (4 * delta / sigman2 / hhss + 2 * log(hms / hps) / sigman3) +
|
eng = -1 * coeff2 * (4 * delta / sigman2 / hhss + 2 * log(hms / hps) / sigman3) +
|
||||||
coeff1 * (35 * delta5 + 70 * delta3 * sigman2 + 15 * delta * sigman4) / hhss7;
|
coeff1 * (35 * delta5 + 70 * delta3 * sigman2 + 15 * delta * sigman4) / hhss7;
|
||||||
|
|
||||||
twall = coeff6 * (6*delta3/sigman4/hhss2 - 10*delta/sigman2/hhss2
|
twall = coeff6 *
|
||||||
+ 3*log(hms/hps)/sigman5)
|
(6 * delta3 / sigman4 / hhss2 - 10 * delta / sigman2 / hhss2 +
|
||||||
+ coeff5 * (21.*delta5 + 30.*delta3*sigman2 + 5.*delta*sigman4) / hhss8;
|
3 * log(hms / hps) / sigman5) +
|
||||||
|
coeff5 * (21. * delta5 + 30. * delta3 * sigman2 + 5. * delta * sigman4) / hhss8;
|
||||||
|
|
||||||
MathExtra::matvec(Lx, nhat, tempvec);
|
MathExtra::matvec(Lx, nhat, tempvec);
|
||||||
MathExtra::transpose_matvec(A, tempvec, tempvec2);
|
MathExtra::transpose_matvec(A, tempvec, tempvec2);
|
||||||
@ -377,6 +377,5 @@ void FixWallRegionEES::ees(int m, int i)
|
|||||||
for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k];
|
for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k];
|
||||||
that[2] = MathExtra::dot3(SAn, tempvec2);
|
that[2] = MathExtra::dot3(SAn, tempvec2);
|
||||||
|
|
||||||
for (int j = 0; j<3 ; j++)
|
for (int j = 0; j < 3; j++) torque[j] = twall * that[j];
|
||||||
torque[j] = twall * that[j];
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,12 +41,12 @@ class FixWallRegionEES : public Fix {
|
|||||||
private:
|
private:
|
||||||
class AtomVecEllipsoid *avec;
|
class AtomVecEllipsoid *avec;
|
||||||
|
|
||||||
int iregion;
|
|
||||||
double epsilon, sigma, cutoff;
|
double epsilon, sigma, cutoff;
|
||||||
int eflag;
|
int eflag;
|
||||||
double ewall[4], ewall_all[4];
|
double ewall[4], ewall_all[4];
|
||||||
int nlevels_respa;
|
int nlevels_respa;
|
||||||
char *idregion;
|
char *idregion;
|
||||||
|
class Region *region;
|
||||||
|
|
||||||
double coeff1, coeff2, coeff3, coeff4, offset;
|
double coeff1, coeff2, coeff3, coeff4, offset;
|
||||||
double coeff5, coeff6;
|
double coeff5, coeff6;
|
||||||
|
|||||||
@ -34,7 +34,8 @@ using namespace MathConst;
|
|||||||
BondGaussian::BondGaussian(LAMMPS *lmp) :
|
BondGaussian::BondGaussian(LAMMPS *lmp) :
|
||||||
Bond(lmp), nterms(nullptr), bond_temperature(nullptr), alpha(nullptr), width(nullptr),
|
Bond(lmp), nterms(nullptr), bond_temperature(nullptr), alpha(nullptr), width(nullptr),
|
||||||
r0(nullptr)
|
r0(nullptr)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|||||||
@ -345,13 +345,11 @@ void DihedralNHarmonic::born_matrix(int nd, int i1, int i2, int i3, int i4,
|
|||||||
double &dudih, double &du2dih) {
|
double &dudih, double &du2dih) {
|
||||||
int i,type;
|
int i,type;
|
||||||
double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,vb2xm,vb2ym,vb2zm;
|
double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,vb2xm,vb2ym,vb2zm;
|
||||||
double ax,ay,az,bx,by,bz,rasq,rbsq,rgsq,rg,rginv,ra2inv,rb2inv,rabinv;
|
double c,ax,ay,az,bx,by,bz,rasq,rbsq,ra2inv,rb2inv,rabinv;
|
||||||
double c,s,kf;
|
|
||||||
|
|
||||||
int **dihedrallist = neighbor->dihedrallist;
|
int **dihedrallist = neighbor->dihedrallist;
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
|
|
||||||
int ndihedrallist = neighbor->ndihedrallist;
|
|
||||||
type = dihedrallist[nd][4];
|
type = dihedrallist[nd][4];
|
||||||
|
|
||||||
vb1x = x[i1][0] - x[i2][0];
|
vb1x = x[i1][0] - x[i2][0];
|
||||||
|
|||||||
@ -38,7 +38,8 @@ class PairLJSmoothLinear : public Pair {
|
|||||||
void write_restart_settings(FILE *) override;
|
void write_restart_settings(FILE *) override;
|
||||||
void read_restart_settings(FILE *) override;
|
void read_restart_settings(FILE *) override;
|
||||||
double single(int, int, int, int, double, double, double, double &) override;
|
double single(int, int, int, int, double, double, double, double &) override;
|
||||||
double single_hessian(int, int, int, int, double, double[3], double, double, double &, double[6]) override;
|
double single_hessian(int, int, int, int, double, double[3], double, double, double &,
|
||||||
|
double[6]) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double cut_global;
|
double cut_global;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ namespace LAMMPS_NS {
|
|||||||
|
|
||||||
class ComputeFEPTA : public Compute {
|
class ComputeFEPTA : public Compute {
|
||||||
public:
|
public:
|
||||||
ComputeFEPTA(class LAMMPS *, int, char **); // compute ID groupID fep/ta temp xy/xz/yz scale_factor
|
ComputeFEPTA(class LAMMPS *, int, char **);
|
||||||
~ComputeFEPTA() override;
|
~ComputeFEPTA() override;
|
||||||
void init() override;
|
void init() override;
|
||||||
void compute_vector() override;
|
void compute_vector() override;
|
||||||
|
|||||||
@ -78,10 +78,12 @@ inline void check_flag(int error_flag, LAMMPS_NS::Error *error, MPI_Comm &world)
|
|||||||
else if (all_success == -13)
|
else if (all_success == -13)
|
||||||
error->all(FLERR, "Invalid device configuration.");
|
error->all(FLERR, "Invalid device configuration.");
|
||||||
else if (all_success == -15)
|
else if (all_success == -15)
|
||||||
error->all(FLERR, "PPPM was compiled for double precision floating point "
|
error->all(FLERR,
|
||||||
|
"PPPM was compiled for double precision floating point "
|
||||||
"but GPU device supports single precision only.");
|
"but GPU device supports single precision only.");
|
||||||
else if (all_success == -16)
|
else if (all_success == -16)
|
||||||
error->all(FLERR, "GPU library was compiled for double or mixed precision "
|
error->all(FLERR,
|
||||||
|
"GPU library was compiled for double or mixed precision "
|
||||||
"floating point but GPU device supports single precision only.");
|
"floating point but GPU device supports single precision only.");
|
||||||
else
|
else
|
||||||
error->all(FLERR, "Unknown error in GPU library");
|
error->all(FLERR, "Unknown error in GPU library");
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -37,26 +36,27 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
using namespace MathConst;
|
using MathConst::MY_2PI;
|
||||||
|
using MathConst::MY_4PI3;
|
||||||
|
using MathConst::MY_PI;
|
||||||
|
|
||||||
enum { ATOM, MOLECULE };
|
enum { ATOM, MOLECULE };
|
||||||
enum { ONE, RANGE, POLY };
|
enum { ONE, RANGE, POLY };
|
||||||
|
|
||||||
#define EPSILON 0.001
|
static constexpr double EPSILON = 0.001;
|
||||||
#define SMALL 1.0e-10
|
static constexpr double SMALL = 1.0e-10;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
|
FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg), radius_poly(nullptr), frac_poly(nullptr),
|
Fix(lmp, narg, arg), radius_poly(nullptr), frac_poly(nullptr), idrigid(nullptr),
|
||||||
idrigid(nullptr), idshake(nullptr), onemols(nullptr), molfrac(nullptr), coords(nullptr),
|
idshake(nullptr), idregion(nullptr), region(nullptr), onemols(nullptr), molfrac(nullptr),
|
||||||
imageflags(nullptr), fixrigid(nullptr), fixshake(nullptr), recvcounts(nullptr),
|
coords(nullptr), imageflags(nullptr), fixrigid(nullptr), fixshake(nullptr), recvcounts(nullptr),
|
||||||
displs(nullptr), random(nullptr), random2(nullptr)
|
displs(nullptr), random(nullptr), random2(nullptr)
|
||||||
{
|
{
|
||||||
if (narg < 6) error->all(FLERR, "Illegal fix pour command");
|
if (narg < 6) error->all(FLERR, "Illegal fix pour command");
|
||||||
|
|
||||||
if (lmp->kokkos)
|
if (lmp->kokkos) error->all(FLERR, "Cannot yet use fix pour with the KOKKOS package");
|
||||||
error->all(FLERR,"Cannot yet use fix pour with the KOKKOS package");
|
|
||||||
|
|
||||||
time_depend = 1;
|
time_depend = 1;
|
||||||
|
|
||||||
@ -82,57 +82,51 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
// error checks on region and its extent being inside simulation box
|
// error checks on region and its extent being inside simulation box
|
||||||
|
|
||||||
if (iregion == -1) error->all(FLERR,"Must specify a region in fix pour");
|
if (!region) error->all(FLERR, "Must specify a region in fix pour");
|
||||||
if (domain->regions[iregion]->bboxflag == 0)
|
if (region->bboxflag == 0)
|
||||||
error->all(FLERR,"Fix pour region does not support a bounding box");
|
error->all(FLERR, "Fix pour region {} does not support a bounding box", idregion);
|
||||||
if (domain->regions[iregion]->dynamic_check())
|
if (region->dynamic_check()) error->all(FLERR, "Fix pour region {} cannot be dynamic", idregion);
|
||||||
error->all(FLERR,"Fix pour region cannot be dynamic");
|
|
||||||
|
|
||||||
if (strcmp(domain->regions[iregion]->style,"block") == 0) {
|
if (strcmp(region->style, "block") == 0) {
|
||||||
|
auto block = dynamic_cast<RegBlock *>(region);
|
||||||
region_style = 1;
|
region_style = 1;
|
||||||
xlo = (dynamic_cast<RegBlock *>( domain->regions[iregion]))->xlo;
|
xlo = block->xlo;
|
||||||
xhi = (dynamic_cast<RegBlock *>( domain->regions[iregion]))->xhi;
|
xhi = block->xhi;
|
||||||
ylo = (dynamic_cast<RegBlock *>( domain->regions[iregion]))->ylo;
|
ylo = block->ylo;
|
||||||
yhi = (dynamic_cast<RegBlock *>( domain->regions[iregion]))->yhi;
|
yhi = block->yhi;
|
||||||
zlo = (dynamic_cast<RegBlock *>( domain->regions[iregion]))->zlo;
|
zlo = block->zlo;
|
||||||
zhi = (dynamic_cast<RegBlock *>( domain->regions[iregion]))->zhi;
|
zhi = block->zhi;
|
||||||
if (xlo < domain->boxlo[0] || xhi > domain->boxhi[0] ||
|
if (xlo < domain->boxlo[0] || xhi > domain->boxhi[0] || ylo < domain->boxlo[1] ||
|
||||||
ylo < domain->boxlo[1] || yhi > domain->boxhi[1] ||
|
yhi > domain->boxhi[1] || zlo < domain->boxlo[2] || zhi > domain->boxhi[2])
|
||||||
zlo < domain->boxlo[2] || zhi > domain->boxhi[2])
|
|
||||||
error->all(FLERR, "Insertion region extends outside simulation box");
|
error->all(FLERR, "Insertion region extends outside simulation box");
|
||||||
} else if (strcmp(domain->regions[iregion]->style,"cylinder") == 0) {
|
} else if (strcmp(region->style, "cylinder") == 0) {
|
||||||
|
auto cylinder = dynamic_cast<RegCylinder *>(region);
|
||||||
region_style = 2;
|
region_style = 2;
|
||||||
char axis = (dynamic_cast<RegCylinder *>( domain->regions[iregion]))->axis;
|
char axis = cylinder->axis;
|
||||||
xc = (dynamic_cast<RegCylinder *>( domain->regions[iregion]))->c1;
|
xc = cylinder->c1;
|
||||||
yc = (dynamic_cast<RegCylinder *>( domain->regions[iregion]))->c2;
|
yc = cylinder->c2;
|
||||||
rc = (dynamic_cast<RegCylinder *>( domain->regions[iregion]))->radius;
|
rc = cylinder->radius;
|
||||||
zlo = (dynamic_cast<RegCylinder *>( domain->regions[iregion]))->lo;
|
zlo = cylinder->lo;
|
||||||
zhi = (dynamic_cast<RegCylinder *>( domain->regions[iregion]))->hi;
|
zhi = cylinder->hi;
|
||||||
if (axis != 'z')
|
if (axis != 'z') error->all(FLERR, "Must use a z-axis cylinder region with fix pour");
|
||||||
error->all(FLERR,"Must use a z-axis cylinder region with fix pour");
|
if (xc - rc < domain->boxlo[0] || xc + rc > domain->boxhi[0] || yc - rc < domain->boxlo[1] ||
|
||||||
if (xc-rc < domain->boxlo[0] || xc+rc > domain->boxhi[0] ||
|
yc + rc > domain->boxhi[1] || zlo < domain->boxlo[2] || zhi > domain->boxhi[2])
|
||||||
yc-rc < domain->boxlo[1] || yc+rc > domain->boxhi[1] ||
|
|
||||||
zlo < domain->boxlo[2] || zhi > domain->boxhi[2])
|
|
||||||
error->all(FLERR, "Insertion region extends outside simulation box");
|
error->all(FLERR, "Insertion region extends outside simulation box");
|
||||||
} else error->all(FLERR,"Must use a block or cylinder region with fix pour");
|
} else
|
||||||
|
error->all(FLERR, "Must use a block or cylinder region with fix pour");
|
||||||
|
|
||||||
if (region_style == 2 && domain->dimension == 2)
|
if (region_style == 2 && domain->dimension == 2)
|
||||||
error->all(FLERR,
|
error->all(FLERR, "Must use a block region with fix pour for 2d simulations");
|
||||||
"Must use a block region with fix pour for 2d simulations");
|
|
||||||
|
|
||||||
// error check and further setup for mode = MOLECULE
|
// error check and further setup for mode = MOLECULE
|
||||||
|
|
||||||
if (atom->tag_enable == 0)
|
if (atom->tag_enable == 0) error->all(FLERR, "Cannot use fix_pour unless atoms have IDs");
|
||||||
error->all(FLERR,"Cannot use fix_pour unless atoms have IDs");
|
|
||||||
|
|
||||||
if (mode == MOLECULE) {
|
if (mode == MOLECULE) {
|
||||||
for (int i = 0; i < nmol; i++) {
|
for (int i = 0; i < nmol; i++) {
|
||||||
if (onemols[i]->xflag == 0)
|
if (onemols[i]->xflag == 0) error->all(FLERR, "Fix pour molecule must have coordinates");
|
||||||
error->all(FLERR,"Fix pour molecule must have coordinates");
|
if (onemols[i]->typeflag == 0) error->all(FLERR, "Fix pour molecule must have atom types");
|
||||||
if (onemols[i]->typeflag == 0)
|
if (ntype + onemols[i]->ntypes <= 0 || ntype + onemols[i]->ntypes > atom->ntypes)
|
||||||
error->all(FLERR,"Fix pour molecule must have atom types");
|
|
||||||
if (ntype+onemols[i]->ntypes <= 0 ||
|
|
||||||
ntype+onemols[i]->ntypes > atom->ntypes)
|
|
||||||
error->all(FLERR, "Invalid atom type in fix pour mol command");
|
error->all(FLERR, "Invalid atom type in fix pour mol command");
|
||||||
|
|
||||||
if (atom->molecular == Atom::TEMPLATE && onemols != atom->avec->onemols)
|
if (atom->molecular == Atom::TEMPLATE && onemols != atom->avec->onemols)
|
||||||
@ -145,20 +139,17 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rigidflag && mode == ATOM)
|
if (rigidflag && mode == ATOM) error->all(FLERR, "Cannot use fix pour rigid and not molecule");
|
||||||
error->all(FLERR,"Cannot use fix pour rigid and not molecule");
|
if (shakeflag && mode == ATOM) error->all(FLERR, "Cannot use fix pour shake and not molecule");
|
||||||
if (shakeflag && mode == ATOM)
|
if (rigidflag && shakeflag) error->all(FLERR, "Cannot use fix pour rigid and shake");
|
||||||
error->all(FLERR,"Cannot use fix pour shake and not molecule");
|
|
||||||
if (rigidflag && shakeflag)
|
|
||||||
error->all(FLERR,"Cannot use fix pour rigid and shake");
|
|
||||||
|
|
||||||
// setup of coords and imageflags array
|
// setup of coords and imageflags array
|
||||||
|
|
||||||
if (mode == ATOM) natom_max = 1;
|
if (mode == ATOM)
|
||||||
|
natom_max = 1;
|
||||||
else {
|
else {
|
||||||
natom_max = 0;
|
natom_max = 0;
|
||||||
for (int i = 0; i < nmol; i++)
|
for (int i = 0; i < nmol; i++) natom_max = MAX(natom_max, onemols[i]->natoms);
|
||||||
natom_max = MAX(natom_max,onemols[i]->natoms);
|
|
||||||
}
|
}
|
||||||
memory->create(coords, natom_max, 4, "pour:coords");
|
memory->create(coords, natom_max, 4, "pour:coords");
|
||||||
memory->create(imageflags, natom_max, "pour:imageflags");
|
memory->create(imageflags, natom_max, "pour:imageflags");
|
||||||
@ -228,8 +219,7 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
molradius_max = 0.0;
|
molradius_max = 0.0;
|
||||||
if (mode == MOLECULE) {
|
if (mode == MOLECULE) {
|
||||||
for (int i = 0; i < nmol; i++)
|
for (int i = 0; i < nmol; i++) molradius_max = MAX(molradius_max, onemols[i]->molradius);
|
||||||
molradius_max = MAX(molradius_max,onemols[i]->molradius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (domain->dimension == 3) {
|
if (domain->dimension == 3) {
|
||||||
@ -237,16 +227,16 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
double dy = yhi - ylo;
|
double dy = yhi - ylo;
|
||||||
if (dy < 1.0) dy = 1.0;
|
if (dy < 1.0) dy = 1.0;
|
||||||
volume = (xhi - xlo) * dy * (zhi - zlo);
|
volume = (xhi - xlo) * dy * (zhi - zlo);
|
||||||
} else volume = MY_PI*rc*rc * (zhi-zlo);
|
} else
|
||||||
|
volume = MY_PI * rc * rc * (zhi - zlo);
|
||||||
if (mode == MOLECULE) {
|
if (mode == MOLECULE) {
|
||||||
volume_one = 4.0/3.0 * MY_PI * molradius_max*molradius_max*molradius_max;
|
volume_one = MY_4PI3 * molradius_max * molradius_max * molradius_max;
|
||||||
} else if (dstyle == ONE || dstyle == RANGE) {
|
} else if (dstyle == ONE || dstyle == RANGE) {
|
||||||
volume_one = 4.0/3.0 * MY_PI * radius_max*radius_max*radius_max;
|
volume_one = MY_4PI3 * radius_max * radius_max * radius_max;
|
||||||
} else if (dstyle == POLY) {
|
} else if (dstyle == POLY) {
|
||||||
volume_one = 0.0;
|
volume_one = 0.0;
|
||||||
for (int i = 0; i < npoly; i++)
|
for (int i = 0; i < npoly; i++)
|
||||||
volume_one += (4.0/3.0 * MY_PI *
|
volume_one += (MY_4PI3 * radius_poly[i] * radius_poly[i] * radius_poly[i]) * frac_poly[i];
|
||||||
radius_poly[i]*radius_poly[i]*radius_poly[i]) * frac_poly[i];
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
volume = (xhi - xlo) * (yhi - ylo);
|
volume = (xhi - xlo) * (yhi - ylo);
|
||||||
@ -268,8 +258,8 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// print stats
|
// print stats
|
||||||
|
|
||||||
if (me == 0)
|
if (me == 0)
|
||||||
utils::logmesg(lmp, "Particle insertion: {} every {} steps, {} by step {}\n",
|
utils::logmesg(lmp, "Particle insertion: {} every {} steps, {} by step {}\n", nper, nfreq,
|
||||||
nper,nfreq,ninsert,nfinal);
|
ninsert, nfinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -301,8 +291,10 @@ int FixPour::setmask()
|
|||||||
|
|
||||||
void FixPour::init()
|
void FixPour::init()
|
||||||
{
|
{
|
||||||
if (domain->triclinic)
|
if (domain->triclinic) error->all(FLERR, "Cannot use fix pour with triclinic box");
|
||||||
error->all(FLERR,"Cannot use fix pour with triclinic box");
|
|
||||||
|
region = domain->get_region_by_id(idregion);
|
||||||
|
if (!region) error->all(FLERR, "Fix pour region {} does not exist", idregion);
|
||||||
|
|
||||||
// insure gravity fix (still) exists
|
// insure gravity fix (still) exists
|
||||||
// for 3d must point in -z, for 2d must point in -y
|
// for 3d must point in -z, for 2d must point in -y
|
||||||
@ -320,12 +312,10 @@ void FixPour::init()
|
|||||||
double zgrav = fixgrav->zgrav;
|
double zgrav = fixgrav->zgrav;
|
||||||
|
|
||||||
if (domain->dimension == 3) {
|
if (domain->dimension == 3) {
|
||||||
if (fabs(xgrav) > EPSILON || fabs(ygrav) > EPSILON ||
|
if (fabs(xgrav) > EPSILON || fabs(ygrav) > EPSILON || fabs(zgrav + 1.0) > EPSILON)
|
||||||
fabs(zgrav+1.0) > EPSILON)
|
|
||||||
error->all(FLERR, "Gravity must point in -z to use with fix pour in 3d");
|
error->all(FLERR, "Gravity must point in -z to use with fix pour in 3d");
|
||||||
} else {
|
} else {
|
||||||
if (fabs(xgrav) > EPSILON || fabs(ygrav+1.0) > EPSILON ||
|
if (fabs(xgrav) > EPSILON || fabs(ygrav + 1.0) > EPSILON || fabs(zgrav) > EPSILON)
|
||||||
fabs(zgrav) > EPSILON)
|
|
||||||
error->all(FLERR, "Gravity must point in -y to use with fix pour in 2d");
|
error->all(FLERR, "Gravity must point in -y to use with fix pour in 2d");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +327,7 @@ void FixPour::init()
|
|||||||
|
|
||||||
if (rigidflag) {
|
if (rigidflag) {
|
||||||
fixrigid = modify->get_fix_by_id(idrigid);
|
fixrigid = modify->get_fix_by_id(idrigid);
|
||||||
if (!fixrigid) error->all(FLERR,"Fix pour rigid fix does not exist");
|
if (!fixrigid) error->all(FLERR, "Fix pour rigid fix {} does not exist", idrigid);
|
||||||
int tmp;
|
int tmp;
|
||||||
if (onemols != (Molecule **) fixrigid->extract("onemol", tmp))
|
if (onemols != (Molecule **) fixrigid->extract("onemol", tmp))
|
||||||
error->all(FLERR, "Fix pour and fix rigid/small not using same molecule template ID");
|
error->all(FLERR, "Fix pour and fix rigid/small not using same molecule template ID");
|
||||||
@ -348,7 +338,7 @@ void FixPour::init()
|
|||||||
|
|
||||||
if (shakeflag) {
|
if (shakeflag) {
|
||||||
fixshake = modify->get_fix_by_id(idshake);
|
fixshake = modify->get_fix_by_id(idshake);
|
||||||
if (!fixshake) error->all(FLERR,"Fix pour shake fix does not exist");
|
if (!fixshake) error->all(FLERR, "Fix pour shake fix {} does not exist", idshake);
|
||||||
int tmp;
|
int tmp;
|
||||||
if (onemols != (Molecule **) fixshake->extract("onemol", tmp))
|
if (onemols != (Molecule **) fixshake->extract("onemol", tmp))
|
||||||
error->all(FLERR, "Fix pour and fix shake not using same molecule template ID");
|
error->all(FLERR, "Fix pour and fix shake not using same molecule template ID");
|
||||||
@ -359,8 +349,10 @@ void FixPour::init()
|
|||||||
|
|
||||||
void FixPour::setup_pre_exchange()
|
void FixPour::setup_pre_exchange()
|
||||||
{
|
{
|
||||||
if (ninserted < ninsert) next_reneighbor = update->ntimestep + 1;
|
if (ninserted < ninsert)
|
||||||
else next_reneighbor = 0;
|
next_reneighbor = update->ntimestep + 1;
|
||||||
|
else
|
||||||
|
next_reneighbor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -452,8 +444,7 @@ void FixPour::pre_exchange()
|
|||||||
|
|
||||||
double *ptr = nullptr;
|
double *ptr = nullptr;
|
||||||
if (ncount) ptr = xmine[0];
|
if (ncount) ptr = xmine[0];
|
||||||
MPI_Allgatherv(ptr,4*ncount,MPI_DOUBLE,
|
MPI_Allgatherv(ptr, 4 * ncount, MPI_DOUBLE, xnear[0], recvcounts, displs, MPI_DOUBLE, world);
|
||||||
xnear[0],recvcounts,displs,MPI_DOUBLE,world);
|
|
||||||
|
|
||||||
// insert new particles into xnear list, one by one
|
// insert new particles into xnear list, one by one
|
||||||
// check against all nearby atoms and previously inserted ones
|
// check against all nearby atoms and previously inserted ones
|
||||||
@ -495,8 +486,7 @@ void FixPour::pre_exchange()
|
|||||||
coords[0][1] = coord[1];
|
coords[0][1] = coord[1];
|
||||||
coords[0][2] = coord[2];
|
coords[0][2] = coord[2];
|
||||||
coords[0][3] = radtmp;
|
coords[0][3] = radtmp;
|
||||||
imageflags[0] = ((imageint) IMGMAX << IMG2BITS) |
|
imageflags[0] = ((imageint) IMGMAX << IMG2BITS) | ((imageint) IMGMAX << IMGBITS) | IMGMAX;
|
||||||
((imageint) IMGMAX << IMGBITS) | IMGMAX;
|
|
||||||
} else {
|
} else {
|
||||||
double rng = random->uniform();
|
double rng = random->uniform();
|
||||||
imol = 0;
|
imol = 0;
|
||||||
@ -526,10 +516,10 @@ void FixPour::pre_exchange()
|
|||||||
|
|
||||||
if (onemols[imol]->radiusflag)
|
if (onemols[imol]->radiusflag)
|
||||||
coords[i][3] = onemols[imol]->radius[i];
|
coords[i][3] = onemols[imol]->radius[i];
|
||||||
else coords[i][3] = 0.5;
|
else
|
||||||
|
coords[i][3] = 0.5;
|
||||||
|
|
||||||
imageflags[i] = ((imageint) IMGMAX << IMG2BITS) |
|
imageflags[i] = ((imageint) IMGMAX << IMG2BITS) | ((imageint) IMGMAX << IMGBITS) | IMGMAX;
|
||||||
((imageint) IMGMAX << IMGBITS) | IMGMAX;
|
|
||||||
domain->remap(coords[i], imageflags[i]);
|
domain->remap(coords[i], imageflags[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -597,37 +587,39 @@ void FixPour::pre_exchange()
|
|||||||
// set group mask to "all" plus fix group
|
// set group mask to "all" plus fix group
|
||||||
|
|
||||||
for (m = 0; m < natom; m++) {
|
for (m = 0; m < natom; m++) {
|
||||||
if (mode == ATOM)
|
if (mode == ATOM) denstmp = density_lo + random->uniform() * (density_hi - density_lo);
|
||||||
denstmp = density_lo + random->uniform() * (density_hi-density_lo);
|
|
||||||
newcoord = coords[m];
|
newcoord = coords[m];
|
||||||
|
|
||||||
flag = 0;
|
flag = 0;
|
||||||
if (newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] &&
|
if (newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] && newcoord[1] >= sublo[1] &&
|
||||||
newcoord[1] >= sublo[1] && newcoord[1] < subhi[1] &&
|
newcoord[1] < subhi[1] && newcoord[2] >= sublo[2] && newcoord[2] < subhi[2])
|
||||||
newcoord[2] >= sublo[2] && newcoord[2] < subhi[2]) flag = 1;
|
flag = 1;
|
||||||
else if (dimension == 3 && newcoord[2] >= domain->boxhi[2]) {
|
else if (dimension == 3 && newcoord[2] >= domain->boxhi[2]) {
|
||||||
if (comm->layout != Comm::LAYOUT_TILED) {
|
if (comm->layout != Comm::LAYOUT_TILED) {
|
||||||
if (comm->myloc[2] == comm->procgrid[2]-1 &&
|
if (comm->myloc[2] == comm->procgrid[2] - 1 && newcoord[0] >= sublo[0] &&
|
||||||
newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] &&
|
newcoord[0] < subhi[0] && newcoord[1] >= sublo[1] && newcoord[1] < subhi[1])
|
||||||
newcoord[1] >= sublo[1] && newcoord[1] < subhi[1]) flag = 1;
|
flag = 1;
|
||||||
} else {
|
} else {
|
||||||
if (comm->mysplit[2][1] == 1.0 &&
|
if (comm->mysplit[2][1] == 1.0 && newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] &&
|
||||||
newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] &&
|
newcoord[1] >= sublo[1] && newcoord[1] < subhi[1])
|
||||||
newcoord[1] >= sublo[1] && newcoord[1] < subhi[1]) flag = 1;
|
flag = 1;
|
||||||
}
|
}
|
||||||
} else if (dimension == 2 && newcoord[1] >= domain->boxhi[1]) {
|
} else if (dimension == 2 && newcoord[1] >= domain->boxhi[1]) {
|
||||||
if (comm->layout != Comm::LAYOUT_TILED) {
|
if (comm->layout != Comm::LAYOUT_TILED) {
|
||||||
if (comm->myloc[1] == comm->procgrid[1]-1 &&
|
if (comm->myloc[1] == comm->procgrid[1] - 1 && newcoord[0] >= sublo[0] &&
|
||||||
newcoord[0] >= sublo[0] && newcoord[0] < subhi[0]) flag = 1;
|
newcoord[0] < subhi[0])
|
||||||
|
flag = 1;
|
||||||
} else {
|
} else {
|
||||||
if (comm->mysplit[1][1] == 1.0 &&
|
if (comm->mysplit[1][1] == 1.0 && newcoord[0] >= sublo[0] && newcoord[0] < subhi[0])
|
||||||
newcoord[0] >= sublo[0] && newcoord[0] < subhi[0]) flag = 1;
|
flag = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (mode == ATOM) atom->avec->create_atom(ntype,coords[m]);
|
if (mode == ATOM)
|
||||||
else atom->avec->create_atom(ntype+onemols[imol]->type[m],coords[m]);
|
atom->avec->create_atom(ntype, coords[m]);
|
||||||
|
else
|
||||||
|
atom->avec->create_atom(ntype + onemols[imol]->type[m], coords[m]);
|
||||||
int n = atom->nlocal - 1;
|
int n = atom->nlocal - 1;
|
||||||
atom->tag[n] = maxtag_all + m + 1;
|
atom->tag[n] = maxtag_all + m + 1;
|
||||||
if (mode == MOLECULE) {
|
if (mode == MOLECULE) {
|
||||||
@ -685,8 +677,7 @@ void FixPour::pre_exchange()
|
|||||||
int ninserted_atoms = nnear - nprevious;
|
int ninserted_atoms = nnear - nprevious;
|
||||||
int ninserted_mols = ninserted_atoms / natom;
|
int ninserted_mols = ninserted_atoms / natom;
|
||||||
ninserted += ninserted_mols;
|
ninserted += ninserted_mols;
|
||||||
if (ninserted_mols < nnew && me == 0)
|
if (ninserted_mols < nnew && me == 0) error->warning(FLERR, "Less insertions than requested");
|
||||||
error->warning(FLERR,"Less insertions than requested");
|
|
||||||
|
|
||||||
// reset global natoms,nbonds,etc
|
// reset global natoms,nbonds,etc
|
||||||
// increment maxtag_all and maxmol_all if necessary
|
// increment maxtag_all and maxmol_all if necessary
|
||||||
@ -696,16 +687,14 @@ void FixPour::pre_exchange()
|
|||||||
|
|
||||||
if (ninserted_atoms) {
|
if (ninserted_atoms) {
|
||||||
atom->natoms += ninserted_atoms;
|
atom->natoms += ninserted_atoms;
|
||||||
if (atom->natoms < 0)
|
if (atom->natoms < 0) error->all(FLERR, "Too many total atoms");
|
||||||
error->all(FLERR,"Too many total atoms");
|
|
||||||
if (mode == MOLECULE) {
|
if (mode == MOLECULE) {
|
||||||
atom->nbonds += (bigint) onemols[imol]->nbonds * ninserted_mols;
|
atom->nbonds += (bigint) onemols[imol]->nbonds * ninserted_mols;
|
||||||
atom->nangles += (bigint) onemols[imol]->nangles * ninserted_mols;
|
atom->nangles += (bigint) onemols[imol]->nangles * ninserted_mols;
|
||||||
atom->ndihedrals += (bigint) onemols[imol]->ndihedrals * ninserted_mols;
|
atom->ndihedrals += (bigint) onemols[imol]->ndihedrals * ninserted_mols;
|
||||||
atom->nimpropers += (bigint) onemols[imol]->nimpropers * ninserted_mols;
|
atom->nimpropers += (bigint) onemols[imol]->nimpropers * ninserted_mols;
|
||||||
}
|
}
|
||||||
if (maxtag_all >= MAXTAGINT)
|
if (maxtag_all >= MAXTAGINT) error->all(FLERR, "New atom IDs exceed maximum allowed ID");
|
||||||
error->all(FLERR,"New atom IDs exceed maximum allowed ID");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rebuild atom map
|
// rebuild atom map
|
||||||
@ -722,8 +711,10 @@ void FixPour::pre_exchange()
|
|||||||
|
|
||||||
// next timestep to insert
|
// next timestep to insert
|
||||||
|
|
||||||
if (ninserted < ninsert) next_reneighbor += nfreq;
|
if (ninserted < ninsert)
|
||||||
else next_reneighbor = 0;
|
next_reneighbor += nfreq;
|
||||||
|
else
|
||||||
|
next_reneighbor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -766,8 +757,10 @@ int FixPour::overlap(int i)
|
|||||||
if (ignoretri && atom->tri[i] >= 0) return 0;
|
if (ignoretri && atom->tri[i] >= 0) return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == ATOM) delta = atom->radius[i] + radius_max;
|
if (mode == ATOM)
|
||||||
else delta = atom->radius[i] + molradius_max;
|
delta = atom->radius[i] + radius_max;
|
||||||
|
else
|
||||||
|
delta = atom->radius[i] + molradius_max;
|
||||||
|
|
||||||
double *x = atom->x[i];
|
double *x = atom->x[i];
|
||||||
|
|
||||||
@ -862,8 +855,7 @@ void FixPour::xyz_random(double h, double *coord)
|
|||||||
double FixPour::radius_sample()
|
double FixPour::radius_sample()
|
||||||
{
|
{
|
||||||
if (dstyle == ONE) return radius_one;
|
if (dstyle == ONE) return radius_one;
|
||||||
if (dstyle == RANGE) return radius_lo +
|
if (dstyle == RANGE) return radius_lo + random->uniform() * (radius_hi - radius_lo);
|
||||||
random->uniform()*(radius_hi-radius_lo);
|
|
||||||
|
|
||||||
double value = random->uniform();
|
double value = random->uniform();
|
||||||
|
|
||||||
@ -884,18 +876,13 @@ void FixPour::options(int narg, char **arg)
|
|||||||
{
|
{
|
||||||
// defaults
|
// defaults
|
||||||
|
|
||||||
iregion = -1;
|
|
||||||
mode = ATOM;
|
mode = ATOM;
|
||||||
molfrac = nullptr;
|
|
||||||
rigidflag = 0;
|
rigidflag = 0;
|
||||||
idrigid = nullptr;
|
|
||||||
shakeflag = 0;
|
shakeflag = 0;
|
||||||
idshake = nullptr;
|
|
||||||
idnext = 0;
|
idnext = 0;
|
||||||
ignoreflag = ignoreline = ignoretri = 0;
|
ignoreflag = ignoreline = ignoretri = 0;
|
||||||
dstyle = ONE;
|
dstyle = ONE;
|
||||||
radius_max = radius_one = 0.5;
|
radius_max = radius_one = 0.5;
|
||||||
radius_poly = frac_poly = nullptr;
|
|
||||||
density_lo = density_hi = 1.0;
|
density_lo = density_hi = 1.0;
|
||||||
volfrac = 0.25;
|
volfrac = 0.25;
|
||||||
maxattempt = 50;
|
maxattempt = 50;
|
||||||
@ -906,15 +893,14 @@ void FixPour::options(int narg, char **arg)
|
|||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg], "region") == 0) {
|
if (strcmp(arg[iarg], "region") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix pour command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix pour command");
|
||||||
iregion = domain->find_region(arg[iarg+1]);
|
region = domain->get_region_by_id(arg[iarg + 1]);
|
||||||
if (iregion == -1) error->all(FLERR,"Fix pour region ID does not exist");
|
if (!region) error->all(FLERR, "Fix pour region {} does not exist", arg[iarg + 1]);
|
||||||
|
idregion = utils::strdup(arg[iarg + 1]);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|
||||||
} else if (strcmp(arg[iarg], "mol") == 0) {
|
} else if (strcmp(arg[iarg], "mol") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix pour command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix pour command");
|
||||||
int imol = atom->find_molecule(arg[iarg + 1]);
|
int imol = atom->find_molecule(arg[iarg + 1]);
|
||||||
if (imol == -1)
|
if (imol == -1) error->all(FLERR, "Molecule template ID for fix pour does not exist");
|
||||||
error->all(FLERR,"Molecule template ID for fix pour does not exist");
|
|
||||||
mode = MOLECULE;
|
mode = MOLECULE;
|
||||||
onemols = &atom->molecules[imol];
|
onemols = &atom->molecules[imol];
|
||||||
nmol = onemols[0]->nset;
|
nmol = onemols[0]->nset;
|
||||||
@ -950,9 +936,12 @@ void FixPour::options(int narg, char **arg)
|
|||||||
|
|
||||||
} else if (strcmp(arg[iarg], "id") == 0) {
|
} else if (strcmp(arg[iarg], "id") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix pour command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix pour command");
|
||||||
if (strcmp(arg[iarg+1],"max") == 0) idnext = 0;
|
if (strcmp(arg[iarg + 1], "max") == 0)
|
||||||
else if (strcmp(arg[iarg+1],"next") == 0) idnext = 1;
|
idnext = 0;
|
||||||
else error->all(FLERR,"Illegal fix pour command");
|
else if (strcmp(arg[iarg + 1], "next") == 0)
|
||||||
|
idnext = 1;
|
||||||
|
else
|
||||||
|
error->all(FLERR, "Illegal fix pour command");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|
||||||
} else if (strcmp(arg[iarg], "ignore") == 0) {
|
} else if (strcmp(arg[iarg], "ignore") == 0) {
|
||||||
@ -982,8 +971,7 @@ void FixPour::options(int narg, char **arg)
|
|||||||
dstyle = POLY;
|
dstyle = POLY;
|
||||||
npoly = utils::inumeric(FLERR, arg[iarg + 2], false, lmp);
|
npoly = utils::inumeric(FLERR, arg[iarg + 2], false, lmp);
|
||||||
if (npoly <= 0) error->all(FLERR, "Illegal fix pour command");
|
if (npoly <= 0) error->all(FLERR, "Illegal fix pour command");
|
||||||
if (iarg+3 + 2*npoly > narg)
|
if (iarg + 3 + 2 * npoly > narg) error->all(FLERR, "Illegal fix pour command");
|
||||||
error->all(FLERR,"Illegal fix pour command");
|
|
||||||
radius_poly = new double[npoly];
|
radius_poly = new double[npoly];
|
||||||
frac_poly = new double[npoly];
|
frac_poly = new double[npoly];
|
||||||
iarg += 3;
|
iarg += 3;
|
||||||
@ -999,7 +987,8 @@ void FixPour::options(int narg, char **arg)
|
|||||||
for (int i = 0; i < npoly; i++) sum += frac_poly[i];
|
for (int i = 0; i < npoly; i++) sum += frac_poly[i];
|
||||||
if (fabs(sum - 1.0) > SMALL)
|
if (fabs(sum - 1.0) > SMALL)
|
||||||
error->all(FLERR, "Fix pour polydisperse fractions do not sum to 1.0");
|
error->all(FLERR, "Fix pour polydisperse fractions do not sum to 1.0");
|
||||||
} else error->all(FLERR,"Illegal fix pour command");
|
} else
|
||||||
|
error->all(FLERR, "Illegal fix pour command");
|
||||||
|
|
||||||
} else if (strcmp(arg[iarg], "dens") == 0) {
|
} else if (strcmp(arg[iarg], "dens") == 0) {
|
||||||
if (iarg + 3 > narg) error->all(FLERR, "Illegal fix pour command");
|
if (iarg + 3 > narg) error->all(FLERR, "Illegal fix pour command");
|
||||||
@ -1023,8 +1012,7 @@ void FixPour::options(int narg, char **arg)
|
|||||||
vxhi = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
|
vxhi = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
|
||||||
vylo = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
|
vylo = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
|
||||||
vyhi = utils::numeric(FLERR, arg[iarg + 4], false, lmp);
|
vyhi = utils::numeric(FLERR, arg[iarg + 4], false, lmp);
|
||||||
if (vxlo > vxhi || vylo > vyhi)
|
if (vxlo > vxhi || vylo > vyhi) error->all(FLERR, "Illegal fix pour command");
|
||||||
error->all(FLERR,"Illegal fix pour command");
|
|
||||||
vz = utils::numeric(FLERR, arg[iarg + 5], false, lmp);
|
vz = utils::numeric(FLERR, arg[iarg + 5], false, lmp);
|
||||||
iarg += 6;
|
iarg += 6;
|
||||||
} else {
|
} else {
|
||||||
@ -1036,7 +1024,8 @@ void FixPour::options(int narg, char **arg)
|
|||||||
if (vxlo > vxhi) error->all(FLERR, "Illegal fix pour command");
|
if (vxlo > vxhi) error->all(FLERR, "Illegal fix pour command");
|
||||||
iarg += 4;
|
iarg += 4;
|
||||||
}
|
}
|
||||||
} else error->all(FLERR,"Illegal fix pour command");
|
} else
|
||||||
|
error->all(FLERR, "Illegal fix pour command");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1055,8 +1044,10 @@ void *FixPour::extract(const char *str, int &itype)
|
|||||||
{
|
{
|
||||||
if (strcmp(str, "radius") == 0) {
|
if (strcmp(str, "radius") == 0) {
|
||||||
if (mode == ATOM) {
|
if (mode == ATOM) {
|
||||||
if (itype == ntype) oneradius = radius_max;
|
if (itype == ntype)
|
||||||
else oneradius = 0.0;
|
oneradius = radius_max;
|
||||||
|
else
|
||||||
|
oneradius = 0.0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -1076,8 +1067,10 @@ void *FixPour::extract(const char *str, int &itype)
|
|||||||
|
|
||||||
for (int i = 0; i < natoms; i++)
|
for (int i = 0; i < natoms; i++)
|
||||||
if (type[i] + ntype == itype) {
|
if (type[i] + ntype == itype) {
|
||||||
if (radius) oneradius = MAX(oneradius,radius[i]);
|
if (radius)
|
||||||
else oneradius = MAX(oneradius,0.5);
|
oneradius = MAX(oneradius, radius[i]);
|
||||||
|
else
|
||||||
|
oneradius = MAX(oneradius, 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class FixPour : public Fix {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int ninsert, ntype, seed;
|
int ninsert, ntype, seed;
|
||||||
int iregion, mode, idnext, dstyle, npoly, rigidflag, shakeflag;
|
int mode, idnext, dstyle, npoly, rigidflag, shakeflag;
|
||||||
int ignoreflag, ignoreline, ignoretri;
|
int ignoreflag, ignoreline, ignoretri;
|
||||||
double radius_one, radius_max;
|
double radius_one, radius_max;
|
||||||
double radius_lo, radius_hi;
|
double radius_lo, radius_hi;
|
||||||
@ -52,6 +52,8 @@ class FixPour : public Fix {
|
|||||||
double xc, yc, rc;
|
double xc, yc, rc;
|
||||||
double grav;
|
double grav;
|
||||||
char *idrigid, *idshake;
|
char *idrigid, *idshake;
|
||||||
|
char *idregion;
|
||||||
|
class Region *region;
|
||||||
|
|
||||||
class Molecule **onemols;
|
class Molecule **onemols;
|
||||||
int nmol, natom_max;
|
int nmol, natom_max;
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -35,21 +34,16 @@ using namespace FixConst;
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) :
|
FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) :
|
||||||
FixWallGran(lmp, narg, arg), region(nullptr), region_style(nullptr),
|
FixWallGran(lmp, narg, arg), region(nullptr), ncontact(nullptr), walls(nullptr),
|
||||||
ncontact(nullptr),
|
history_many(nullptr), c2r(nullptr)
|
||||||
walls(nullptr), history_many(nullptr), c2r(nullptr)
|
|
||||||
{
|
{
|
||||||
restart_global = 1;
|
restart_global = 1;
|
||||||
motion_resetflag = 0;
|
motion_resetflag = 0;
|
||||||
|
|
||||||
int iregion = domain->find_region(idregion);
|
region = domain->get_region_by_id(idregion);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for fix wall/gran/region does not exist", idregion);
|
||||||
error->all(FLERR,"Region ID for fix wall/gran/region does not exist");
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
region_style = utils::strdup(region->style);
|
|
||||||
nregion = region->nregion;
|
nregion = region->nregion;
|
||||||
|
tmax = region->tmax;
|
||||||
tmax = domain->regions[iregion]->tmax;
|
|
||||||
c2r = new int[tmax];
|
c2r = new int[tmax];
|
||||||
|
|
||||||
// re-allocate atom-based arrays with nshear
|
// re-allocate atom-based arrays with nshear
|
||||||
@ -67,8 +61,7 @@ FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
if (use_history) {
|
if (use_history) {
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++) ncontact[i] = 0;
|
||||||
ncontact[i] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,25 +83,32 @@ void FixWallGranRegion::init()
|
|||||||
{
|
{
|
||||||
FixWallGran::init();
|
FixWallGran::init();
|
||||||
|
|
||||||
int iregion = domain->find_region(idregion);
|
auto newregion = domain->get_region_by_id(idregion);
|
||||||
if (iregion == -1)
|
if (!newregion) error->all(FLERR, "Region {} for fix wall/gran/region does not exist", idregion);
|
||||||
error->all(FLERR,"Region ID for fix wall/gran/region does not exist");
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
|
|
||||||
// check if region properties changed between runs
|
// check if region properties changed between runs
|
||||||
// reset if restart info was inconsistent
|
// reset if restart info was inconsistent
|
||||||
|
|
||||||
if ((strcmp(idregion,region->id) != 0)
|
if (newregion != region) {
|
||||||
|| (strcmp(region_style,region->style) != 0)
|
region = newregion;
|
||||||
|| (nregion != region->nregion)) {
|
if (comm->me == 0)
|
||||||
error->warning(FLERR,"Region properties for region {} changed between "
|
error->warning(FLERR,
|
||||||
"runs, resetting its motion",idregion);
|
"Region properties for region {} changed between runs, resetting its motion",
|
||||||
|
idregion);
|
||||||
|
nregion = region->nregion;
|
||||||
|
tmax = region->tmax;
|
||||||
|
delete[] c2r;
|
||||||
|
c2r = new int[tmax];
|
||||||
|
region = newregion;
|
||||||
region->reset_vel();
|
region->reset_vel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (motion_resetflag) {
|
if (motion_resetflag) {
|
||||||
error->warning(FLERR,"Region properties for region {} are inconsistent "
|
if (comm->me == 0)
|
||||||
"with restart file, resetting its motion",idregion);
|
error->warning(FLERR,
|
||||||
|
"Region properties for region {} are inconsistent with restart file, "
|
||||||
|
"resetting its motion",
|
||||||
|
idregion);
|
||||||
region->reset_vel();
|
region->reset_vel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,8 +142,10 @@ void FixWallGranRegion::post_force(int /*vflag*/)
|
|||||||
}
|
}
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (body[i] >= 0) mass_rigid[i] = mass_body[body[i]];
|
if (body[i] >= 0)
|
||||||
else mass_rigid[i] = 0.0;
|
mass_rigid[i] = mass_body[body[i]];
|
||||||
|
else
|
||||||
|
mass_rigid[i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,23 +171,18 @@ void FixWallGranRegion::post_force(int /*vflag*/)
|
|||||||
region->set_velocity();
|
region->set_velocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peratom_flag) {
|
if (peratom_flag) { clear_stored_contacts(); }
|
||||||
clear_stored_contacts();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (!region->match(x[i][0], x[i][1], x[i][2])) continue;
|
if (!region->match(x[i][0], x[i][1], x[i][2])) continue;
|
||||||
|
|
||||||
if (pairstyle == FixWallGran::GRANULAR && normal_model == FixWallGran::JKR) {
|
if (pairstyle == FixWallGran::GRANULAR && normal_model == FixWallGran::JKR) {
|
||||||
nc = region->surface(x[i][0],x[i][1],x[i][2],
|
nc = region->surface(x[i][0], x[i][1], x[i][2], radius[i] + pulloff_distance(radius[i]));
|
||||||
radius[i]+pulloff_distance(radius[i]));
|
} else {
|
||||||
}
|
|
||||||
else{
|
|
||||||
nc = region->surface(x[i][0], x[i][1], x[i][2], radius[i]);
|
nc = region->surface(x[i][0], x[i][1], x[i][2], radius[i]);
|
||||||
}
|
}
|
||||||
if (nc > tmax)
|
if (nc > tmax) error->one(FLERR, "Too many wall/gran/region contacts for one particle");
|
||||||
error->one(FLERR,"Too many wall/gran/region contacts for one particle");
|
|
||||||
|
|
||||||
// shear history maintenance
|
// shear history maintenance
|
||||||
// update ncontact,walls,shear2many for particle I
|
// update ncontact,walls,shear2many for particle I
|
||||||
@ -204,11 +201,11 @@ void FixWallGranRegion::post_force(int /*vflag*/)
|
|||||||
if (ncontact[i] == 0) {
|
if (ncontact[i] == 0) {
|
||||||
ncontact[i] = 1;
|
ncontact[i] = 1;
|
||||||
walls[i][0] = iwall;
|
walls[i][0] = iwall;
|
||||||
for (m = 0; m < size_history; m++)
|
for (m = 0; m < size_history; m++) history_many[i][0][m] = 0.0;
|
||||||
history_many[i][0][m] = 0.0;
|
|
||||||
} else if (ncontact[i] > 1 || iwall != walls[i][0])
|
} else if (ncontact[i] > 1 || iwall != walls[i][0])
|
||||||
update_contacts(i, nc);
|
update_contacts(i, nc);
|
||||||
} else update_contacts(i,nc);
|
} else
|
||||||
|
update_contacts(i, nc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// process current contacts
|
// process current contacts
|
||||||
@ -221,8 +218,7 @@ void FixWallGranRegion::post_force(int /*vflag*/)
|
|||||||
|
|
||||||
if (pairstyle == FixWallGran::GRANULAR && normal_model == FixWallGran::JKR) {
|
if (pairstyle == FixWallGran::GRANULAR && normal_model == FixWallGran::JKR) {
|
||||||
if (history_many[i][c2r[ic]][0] == 0.0 && rsq > radius[i] * radius[i]) {
|
if (history_many[i][c2r[ic]][0] == 0.0 && rsq > radius[i] * radius[i]) {
|
||||||
for (m = 0; m < size_history; m++)
|
for (m = 0; m < size_history; m++) history_many[i][0][m] = 0.0;
|
||||||
history_many[i][0][m] = 0.0;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,20 +252,16 @@ void FixWallGranRegion::post_force(int /*vflag*/)
|
|||||||
contact = nullptr;
|
contact = nullptr;
|
||||||
|
|
||||||
if (pairstyle == FixWallGran::HOOKE)
|
if (pairstyle == FixWallGran::HOOKE)
|
||||||
hooke(rsq,dx,dy,dz,vwall,v[i],f[i],
|
hooke(rsq, dx, dy, dz, vwall, v[i], f[i], omega[i], torque[i], radius[i], meff, contact);
|
||||||
omega[i],torque[i],radius[i],meff, contact);
|
|
||||||
else if (pairstyle == FixWallGran::HOOKE_HISTORY)
|
else if (pairstyle == FixWallGran::HOOKE_HISTORY)
|
||||||
hooke_history(rsq,dx,dy,dz,vwall,v[i],f[i],
|
hooke_history(rsq, dx, dy, dz, vwall, v[i], f[i], omega[i], torque[i], radius[i], meff,
|
||||||
omega[i],torque[i],radius[i],meff,
|
|
||||||
history_many[i][c2r[ic]], contact);
|
history_many[i][c2r[ic]], contact);
|
||||||
else if (pairstyle == FixWallGran::HERTZ_HISTORY)
|
else if (pairstyle == FixWallGran::HERTZ_HISTORY)
|
||||||
hertz_history(rsq,dx,dy,dz,vwall,region->contact[ic].radius,
|
hertz_history(rsq, dx, dy, dz, vwall, region->contact[ic].radius, v[i], f[i], omega[i],
|
||||||
v[i],f[i],omega[i],torque[i],
|
torque[i], radius[i], meff, history_many[i][c2r[ic]], contact);
|
||||||
radius[i],meff,history_many[i][c2r[ic]], contact);
|
|
||||||
else if (pairstyle == FixWallGran::GRANULAR)
|
else if (pairstyle == FixWallGran::GRANULAR)
|
||||||
granular(rsq,dx,dy,dz,vwall,region->contact[ic].radius,
|
granular(rsq, dx, dy, dz, vwall, region->contact[ic].radius, v[i], f[i], omega[i],
|
||||||
v[i],f[i],omega[i],torque[i],
|
torque[i], radius[i], meff, history_many[i][c2r[ic]], contact);
|
||||||
radius[i],meff,history_many[i][c2r[ic]],contact);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,11 +289,11 @@ void FixWallGranRegion::update_contacts(int i, int nc)
|
|||||||
if (region->contact[m].iwall == walls[i][iold]) break;
|
if (region->contact[m].iwall == walls[i][iold]) break;
|
||||||
if (m >= nc) {
|
if (m >= nc) {
|
||||||
ilast = ncontact[i] - 1;
|
ilast = ncontact[i] - 1;
|
||||||
for (j = 0; j < size_history; j++)
|
for (j = 0; j < size_history; j++) history_many[i][iold][j] = history_many[i][ilast][j];
|
||||||
history_many[i][iold][j] = history_many[i][ilast][j];
|
|
||||||
walls[i][iold] = walls[i][ilast];
|
walls[i][iold] = walls[i][ilast];
|
||||||
ncontact[i]--;
|
ncontact[i]--;
|
||||||
} else iold++;
|
} else
|
||||||
|
iold++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop over new contacts
|
// loop over new contacts
|
||||||
@ -315,13 +307,13 @@ void FixWallGranRegion::update_contacts(int i, int nc)
|
|||||||
iwall = region->contact[inew].iwall;
|
iwall = region->contact[inew].iwall;
|
||||||
for (m = 0; m < nold; m++)
|
for (m = 0; m < nold; m++)
|
||||||
if (walls[i][m] == iwall) break;
|
if (walls[i][m] == iwall) break;
|
||||||
if (m < nold) c2r[m] = inew;
|
if (m < nold)
|
||||||
|
c2r[m] = inew;
|
||||||
else {
|
else {
|
||||||
iadd = ncontact[i];
|
iadd = ncontact[i];
|
||||||
|
|
||||||
c2r[iadd] = inew;
|
c2r[iadd] = inew;
|
||||||
for (j = 0; j < size_history; j++)
|
for (j = 0; j < size_history; j++) history_many[i][iadd][j] = 0.0;
|
||||||
history_many[i][iadd][j] = 0.0;
|
|
||||||
walls[i][iadd] = iwall;
|
walls[i][iadd] = iwall;
|
||||||
ncontact[i]++;
|
ncontact[i]++;
|
||||||
}
|
}
|
||||||
@ -356,8 +348,7 @@ void FixWallGranRegion::grow_arrays(int nmax)
|
|||||||
memory->grow(walls, nmax, tmax, "fix_wall_gran:walls");
|
memory->grow(walls, nmax, tmax, "fix_wall_gran:walls");
|
||||||
memory->grow(history_many, nmax, tmax, size_history, "fix_wall_gran:history_many");
|
memory->grow(history_many, nmax, tmax, size_history, "fix_wall_gran:history_many");
|
||||||
}
|
}
|
||||||
if (peratom_flag)
|
if (peratom_flag) memory->grow(array_atom, nmax, size_peratom_cols, "fix_wall_gran:array_atom");
|
||||||
memory->grow(array_atom,nmax,size_peratom_cols,"fix_wall_gran:array_atom");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -372,15 +363,13 @@ void FixWallGranRegion::copy_arrays(int i, int j, int /*delflag*/)
|
|||||||
n = ncontact[i];
|
n = ncontact[i];
|
||||||
for (iwall = 0; iwall < n; iwall++) {
|
for (iwall = 0; iwall < n; iwall++) {
|
||||||
walls[j][iwall] = walls[i][iwall];
|
walls[j][iwall] = walls[i][iwall];
|
||||||
for (m = 0; m < size_history; m++)
|
for (m = 0; m < size_history; m++) history_many[j][iwall][m] = history_many[i][iwall][m];
|
||||||
history_many[j][iwall][m] = history_many[i][iwall][m];
|
|
||||||
}
|
}
|
||||||
ncontact[j] = ncontact[i];
|
ncontact[j] = ncontact[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peratom_flag) {
|
if (peratom_flag) {
|
||||||
for (int m = 0; m < size_peratom_cols; m++)
|
for (int m = 0; m < size_peratom_cols; m++) array_atom[j][m] = array_atom[i][m];
|
||||||
array_atom[j][m] = array_atom[i][m];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,11 +379,9 @@ void FixWallGranRegion::copy_arrays(int i, int j, int /*delflag*/)
|
|||||||
|
|
||||||
void FixWallGranRegion::set_arrays(int i)
|
void FixWallGranRegion::set_arrays(int i)
|
||||||
{
|
{
|
||||||
if (use_history)
|
if (use_history) ncontact[i] = 0;
|
||||||
ncontact[i] = 0;
|
|
||||||
if (peratom_flag) {
|
if (peratom_flag) {
|
||||||
for (int m = 0; m < size_peratom_cols; m++)
|
for (int m = 0; m < size_peratom_cols; m++) array_atom[i][m] = 0;
|
||||||
array_atom[i][m] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,13 +399,11 @@ int FixWallGranRegion::pack_exchange(int i, double *buf)
|
|||||||
buf[n++] = ubuf(count).d;
|
buf[n++] = ubuf(count).d;
|
||||||
for (int iwall = 0; iwall < count; iwall++) {
|
for (int iwall = 0; iwall < count; iwall++) {
|
||||||
buf[n++] = ubuf(walls[i][iwall]).d;
|
buf[n++] = ubuf(walls[i][iwall]).d;
|
||||||
for (m = 0; m < size_history; m++)
|
for (m = 0; m < size_history; m++) buf[n++] = history_many[i][iwall][m];
|
||||||
buf[n++] = history_many[i][iwall][m];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (peratom_flag) {
|
if (peratom_flag) {
|
||||||
for (int m = 0; m < size_peratom_cols; m++)
|
for (int m = 0; m < size_peratom_cols; m++) buf[n++] = array_atom[i][m];
|
||||||
buf[n++] = array_atom[i][m];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
@ -432,19 +417,16 @@ int FixWallGranRegion::unpack_exchange(int nlocal, double *buf)
|
|||||||
{
|
{
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
if (use_history) {
|
if (use_history) {
|
||||||
int count = ncontact[nlocal] = (int) ubuf(buf[n++]).i;
|
int count = ncontact[nlocal] = (int) ubuf(buf[n++]).i;
|
||||||
for (int iwall = 0; iwall < count; iwall++) {
|
for (int iwall = 0; iwall < count; iwall++) {
|
||||||
walls[nlocal][iwall] = (int) ubuf(buf[n++]).i;
|
walls[nlocal][iwall] = (int) ubuf(buf[n++]).i;
|
||||||
for (m = 0; m < size_history; m++)
|
for (m = 0; m < size_history; m++) history_many[nlocal][iwall][m] = buf[n++];
|
||||||
history_many[nlocal][iwall][m] = buf[n++];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (peratom_flag) {
|
if (peratom_flag) {
|
||||||
for (int m = 0; m < size_peratom_cols; m++)
|
for (int m = 0; m < size_peratom_cols; m++) array_atom[nlocal][m] = buf[n++];
|
||||||
array_atom[nlocal][m] = buf[n++];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
@ -466,8 +448,7 @@ int FixWallGranRegion::pack_restart(int i, double *buf)
|
|||||||
buf[n++] = ubuf(count).d;
|
buf[n++] = ubuf(count).d;
|
||||||
for (int iwall = 0; iwall < count; iwall++) {
|
for (int iwall = 0; iwall < count; iwall++) {
|
||||||
buf[n++] = ubuf(walls[i][iwall]).d;
|
buf[n++] = ubuf(walls[i][iwall]).d;
|
||||||
for (m = 0; m < size_history; m++)
|
for (m = 0; m < size_history; m++) buf[n++] = history_many[i][iwall][m];
|
||||||
buf[n++] = history_many[i][iwall][m];
|
|
||||||
}
|
}
|
||||||
// pack buf[0] this way because other fixes unpack it
|
// pack buf[0] this way because other fixes unpack it
|
||||||
buf[0] = n;
|
buf[0] = n;
|
||||||
@ -496,8 +477,7 @@ void FixWallGranRegion::unpack_restart(int nlocal, int nth)
|
|||||||
int count = ncontact[nlocal] = (int) ubuf(extra[nlocal][m++]).i;
|
int count = ncontact[nlocal] = (int) ubuf(extra[nlocal][m++]).i;
|
||||||
for (int iwall = 0; iwall < count; iwall++) {
|
for (int iwall = 0; iwall < count; iwall++) {
|
||||||
walls[nlocal][iwall] = (int) ubuf(extra[nlocal][m++]).i;
|
walls[nlocal][iwall] = (int) ubuf(extra[nlocal][m++]).i;
|
||||||
for (k = 0; k < size_history; k++)
|
for (k = 0; k < size_history; k++) history_many[nlocal][iwall][k] = extra[nlocal][m++];
|
||||||
history_many[nlocal][iwall][k] = extra[nlocal][m++];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -67,8 +67,8 @@ PairGranHookeHistory::PairGranHookeHistory(LAMMPS *lmp) : Pair(lmp)
|
|||||||
// this is so final order of Modify:fix will conform to input script
|
// this is so final order of Modify:fix will conform to input script
|
||||||
|
|
||||||
fix_history = nullptr;
|
fix_history = nullptr;
|
||||||
fix_dummy = dynamic_cast<FixDummy *>( modify->add_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me) +
|
fix_dummy = dynamic_cast<FixDummy *>(
|
||||||
" all DUMMY"));
|
modify->add_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me) + " all DUMMY"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -443,8 +443,10 @@ void PairGranHookeHistory::init_style()
|
|||||||
|
|
||||||
// need a granular neighbor list
|
// need a granular neighbor list
|
||||||
|
|
||||||
if (history) neighbor->add_request(this, NeighConst::REQ_SIZE|NeighConst::REQ_HISTORY);
|
if (history)
|
||||||
else neighbor->add_request(this, NeighConst::REQ_SIZE);
|
neighbor->add_request(this, NeighConst::REQ_SIZE | NeighConst::REQ_HISTORY);
|
||||||
|
else
|
||||||
|
neighbor->add_request(this, NeighConst::REQ_SIZE);
|
||||||
|
|
||||||
dt = update->dt;
|
dt = update->dt;
|
||||||
|
|
||||||
@ -454,8 +456,8 @@ void PairGranHookeHistory::init_style()
|
|||||||
|
|
||||||
if (history && (fix_history == nullptr)) {
|
if (history && (fix_history == nullptr)) {
|
||||||
auto cmd = fmt::format("NEIGH_HISTORY_HH{} all NEIGH_HISTORY {}", instance_me, size_history);
|
auto cmd = fmt::format("NEIGH_HISTORY_HH{} all NEIGH_HISTORY {}", instance_me, size_history);
|
||||||
fix_history = dynamic_cast<FixNeighHistory *>( modify->replace_fix(
|
fix_history = dynamic_cast<FixNeighHistory *>(
|
||||||
"NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me), cmd, 1));
|
modify->replace_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me), cmd, 1));
|
||||||
fix_history->pair = this;
|
fix_history->pair = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +478,8 @@ void PairGranHookeHistory::init_style()
|
|||||||
if (ifix->rigid_flag) {
|
if (ifix->rigid_flag) {
|
||||||
if (fix_rigid)
|
if (fix_rigid)
|
||||||
error->all(FLERR, "Only one fix rigid command at a time allowed");
|
error->all(FLERR, "Only one fix rigid command at a time allowed");
|
||||||
else fix_rigid = ifix;
|
else
|
||||||
|
fix_rigid = ifix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +524,8 @@ void PairGranHookeHistory::init_style()
|
|||||||
// set fix which stores history info
|
// set fix which stores history info
|
||||||
|
|
||||||
if (history) {
|
if (history) {
|
||||||
fix_history = dynamic_cast<FixNeighHistory *>( modify->get_fix_by_id("NEIGH_HISTORY_HH" + std::to_string(instance_me)));
|
fix_history = dynamic_cast<FixNeighHistory *>(
|
||||||
|
modify->get_fix_by_id("NEIGH_HISTORY_HH" + std::to_string(instance_me)));
|
||||||
if (!fix_history) error->all(FLERR, "Could not find pair fix neigh history ID");
|
if (!fix_history) error->all(FLERR, "Could not find pair fix neigh history ID");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,7 +141,8 @@ void PairKolmogorovCrespiFull::settings(int narg, char **arg)
|
|||||||
{
|
{
|
||||||
if (narg < 1 || narg > 2) error->all(FLERR, "Illegal pair_style command");
|
if (narg < 1 || narg > 2) error->all(FLERR, "Illegal pair_style command");
|
||||||
if (!utils::strmatch(force->pair_style, "^hybrid/overlay"))
|
if (!utils::strmatch(force->pair_style, "^hybrid/overlay"))
|
||||||
error->all(FLERR, "Pair style kolmogorov/crespi/full must be used as sub-style with hybrid/overlay");
|
error->all(FLERR,
|
||||||
|
"Pair style kolmogorov/crespi/full must be used as sub-style with hybrid/overlay");
|
||||||
|
|
||||||
cut_global = utils::numeric(FLERR, arg[0], false, lmp);
|
cut_global = utils::numeric(FLERR, arg[0], false, lmp);
|
||||||
if (narg == 2) tap_flag = utils::numeric(FLERR, arg[1], false, lmp);
|
if (narg == 2) tap_flag = utils::numeric(FLERR, arg[1], false, lmp);
|
||||||
|
|||||||
@ -253,7 +253,8 @@ void KimInit::determine_model_type_and_units(char *model_name, char *user_units,
|
|||||||
KIM_Model_Destroy(&pkim);
|
KIM_Model_Destroy(&pkim);
|
||||||
const char *unit_systems[] = {"metal", "real", "si", "cgs", "electron"};
|
const char *unit_systems[] = {"metal", "real", "si", "cgs", "electron"};
|
||||||
for (auto units : unit_systems) {
|
for (auto units : unit_systems) {
|
||||||
get_kim_unit_names(units, lengthUnit, energyUnit, chargeUnit, temperatureUnit, timeUnit, error);
|
get_kim_unit_names(units, lengthUnit, energyUnit, chargeUnit, temperatureUnit, timeUnit,
|
||||||
|
error);
|
||||||
kim_error = KIM_Model_Create(KIM_NUMBERING_zeroBased, lengthUnit, energyUnit, chargeUnit,
|
kim_error = KIM_Model_Create(KIM_NUMBERING_zeroBased, lengthUnit, energyUnit, chargeUnit,
|
||||||
temperatureUnit, timeUnit, model_name, &units_accepted, &pkim);
|
temperatureUnit, timeUnit, model_name, &units_accepted, &pkim);
|
||||||
if (units_accepted) {
|
if (units_accepted) {
|
||||||
|
|||||||
@ -87,9 +87,7 @@ void FixSetForceKokkos<DeviceType>::post_force(int /*vflag*/)
|
|||||||
|
|
||||||
// update region if necessary
|
// update region if necessary
|
||||||
|
|
||||||
region = nullptr;
|
if (region) {
|
||||||
if (iregion >= 0) {
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
region->prematch();
|
||||||
DAT::tdual_int_1d k_match = DAT::tdual_int_1d("setforce:k_match",nlocal);
|
DAT::tdual_int_1d k_match = DAT::tdual_int_1d("setforce:k_match",nlocal);
|
||||||
KokkosBase* regionKKBase = dynamic_cast<KokkosBase*>(region);
|
KokkosBase* regionKKBase = dynamic_cast<KokkosBase*>(region);
|
||||||
|
|||||||
@ -81,8 +81,6 @@ class FixSetForceKokkos : public FixSetForce {
|
|||||||
typename AT::t_x_array_randomread x;
|
typename AT::t_x_array_randomread x;
|
||||||
typename AT::t_f_array f;
|
typename AT::t_f_array f;
|
||||||
typename AT::t_int_1d_randomread mask;
|
typename AT::t_int_1d_randomread mask;
|
||||||
|
|
||||||
class Region* region;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,8 +31,8 @@ class PPPMDispTIP4P : public PPPMDisp {
|
|||||||
void init() override;
|
void init() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void particle_map_c(double, double, double, double, int **, int, int, int, int, int, int,
|
void particle_map_c(double, double, double, double, int **, int, int, int, int, int, int, int,
|
||||||
int, int) override;
|
int) override;
|
||||||
void make_rho_c() override;
|
void make_rho_c() override;
|
||||||
void fieldforce_c_ik() override;
|
void fieldforce_c_ik() override;
|
||||||
void fieldforce_c_ad() override;
|
void fieldforce_c_ad() override;
|
||||||
|
|||||||
@ -2387,8 +2387,8 @@ void FixLbFluid::dump(const bigint step)
|
|||||||
" </DataItem>\n"
|
" </DataItem>\n"
|
||||||
" </Attribute>\n\n",
|
" </Attribute>\n\n",
|
||||||
dm_lb / (dx_lb * dx_lb * dx_lb), fluid_global_n0[2], fluid_global_n0[1],
|
dm_lb / (dx_lb * dx_lb * dx_lb), fluid_global_n0[2], fluid_global_n0[1],
|
||||||
fluid_global_n0[0], sizeof(double), offset, fluid_global_n0[2],
|
fluid_global_n0[0], sizeof(double), offset, fluid_global_n0[2], fluid_global_n0[1],
|
||||||
fluid_global_n0[1], fluid_global_n0[0], dump_file_name_raw.c_str());
|
fluid_global_n0[0], dump_file_name_raw.c_str());
|
||||||
fmt::print(dump_file_handle_xdmf,
|
fmt::print(dump_file_handle_xdmf,
|
||||||
" <Attribute Name=\"velocity\" AttributeType=\"Vector\">\n"
|
" <Attribute Name=\"velocity\" AttributeType=\"Vector\">\n"
|
||||||
" <DataItem ItemType=\"Function\" Function=\"$0 * {:f}\" "
|
" <DataItem ItemType=\"Function\" Function=\"$0 * {:f}\" "
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* *** Smooth Mach Dynamics ***
|
* *** Smooth Mach Dynamics ***
|
||||||
@ -41,16 +40,15 @@
|
|||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
|
||||||
enum {
|
enum { NONE, CONSTANT, EQUAL, ATOM };
|
||||||
NONE, CONSTANT, EQUAL, ATOM
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixSMDSetVel::FixSMDSetVel(LAMMPS *lmp, int narg, char **arg) :
|
FixSMDSetVel::FixSMDSetVel(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg) {
|
Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), idregion(nullptr),
|
||||||
if (narg < 6)
|
region(nullptr), sforce(nullptr)
|
||||||
error->all(FLERR, "Illegal fix setvelocity command");
|
{
|
||||||
|
if (narg < 6) error->all(FLERR, "Illegal fix setvelocity command");
|
||||||
|
|
||||||
dynamic_group_allow = 1;
|
dynamic_group_allow = 1;
|
||||||
vector_flag = 1;
|
vector_flag = 1;
|
||||||
@ -58,8 +56,6 @@ FixSMDSetVel::FixSMDSetVel(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
global_freq = 1;
|
global_freq = 1;
|
||||||
extvector = 1;
|
extvector = 1;
|
||||||
|
|
||||||
xstr = ystr = zstr = nullptr;
|
|
||||||
|
|
||||||
if (strstr(arg[3], "v_") == arg[3]) {
|
if (strstr(arg[3], "v_") == arg[3]) {
|
||||||
xstr = utils::strdup(&arg[3][2]);
|
xstr = utils::strdup(&arg[3][2]);
|
||||||
} else if (strcmp(arg[3], "NULL") == 0) {
|
} else if (strcmp(arg[3], "NULL") == 0) {
|
||||||
@ -87,17 +83,12 @@ FixSMDSetVel::FixSMDSetVel(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
// optional args
|
// optional args
|
||||||
|
|
||||||
iregion = -1;
|
|
||||||
idregion = nullptr;
|
|
||||||
|
|
||||||
int iarg = 6;
|
int iarg = 6;
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg], "region") == 0) {
|
if (strcmp(arg[iarg], "region") == 0) {
|
||||||
if (iarg + 2 > narg)
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix setvelocity command");
|
||||||
error->all(FLERR, "Illegal fix setvelocity command");
|
region = domain->get_region_by_id(arg[iarg + 1]);
|
||||||
iregion = domain->find_region(arg[iarg + 1]);
|
if (!region) error->all(FLERR, "Region {} for fix setvelocity does not exist", arg[iarg + 1]);
|
||||||
if (iregion == -1)
|
|
||||||
error->all(FLERR, "Region ID for fix setvelocity does not exist");
|
|
||||||
idregion = utils::strdup(arg[iarg + 1]);
|
idregion = utils::strdup(arg[iarg + 1]);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else
|
} else
|
||||||
@ -113,7 +104,8 @@ FixSMDSetVel::FixSMDSetVel(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixSMDSetVel::~FixSMDSetVel() {
|
FixSMDSetVel::~FixSMDSetVel()
|
||||||
|
{
|
||||||
delete[] xstr;
|
delete[] xstr;
|
||||||
delete[] ystr;
|
delete[] ystr;
|
||||||
delete[] zstr;
|
delete[] zstr;
|
||||||
@ -123,22 +115,22 @@ FixSMDSetVel::~FixSMDSetVel() {
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
int FixSMDSetVel::setmask() {
|
int FixSMDSetVel::setmask()
|
||||||
|
{
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
//mask |= INITIAL_INTEGRATE;
|
|
||||||
mask |= POST_FORCE;
|
mask |= POST_FORCE;
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixSMDSetVel::init() {
|
void FixSMDSetVel::init()
|
||||||
|
{
|
||||||
// check variables
|
// check variables
|
||||||
|
|
||||||
if (xstr) {
|
if (xstr) {
|
||||||
xvar = input->variable->find(xstr);
|
xvar = input->variable->find(xstr);
|
||||||
if (xvar < 0)
|
if (xvar < 0) error->all(FLERR, "Variable name for fix setvelocity does not exist");
|
||||||
error->all(FLERR, "Variable name for fix setvelocity does not exist");
|
|
||||||
if (input->variable->equalstyle(xvar))
|
if (input->variable->equalstyle(xvar))
|
||||||
xstyle = EQUAL;
|
xstyle = EQUAL;
|
||||||
else if (input->variable->atomstyle(xvar))
|
else if (input->variable->atomstyle(xvar))
|
||||||
@ -148,8 +140,7 @@ void FixSMDSetVel::init() {
|
|||||||
}
|
}
|
||||||
if (ystr) {
|
if (ystr) {
|
||||||
yvar = input->variable->find(ystr);
|
yvar = input->variable->find(ystr);
|
||||||
if (yvar < 0)
|
if (yvar < 0) error->all(FLERR, "Variable name for fix setvelocity does not exist");
|
||||||
error->all(FLERR, "Variable name for fix setvelocity does not exist");
|
|
||||||
if (input->variable->equalstyle(yvar))
|
if (input->variable->equalstyle(yvar))
|
||||||
ystyle = EQUAL;
|
ystyle = EQUAL;
|
||||||
else if (input->variable->atomstyle(yvar))
|
else if (input->variable->atomstyle(yvar))
|
||||||
@ -159,8 +150,7 @@ void FixSMDSetVel::init() {
|
|||||||
}
|
}
|
||||||
if (zstr) {
|
if (zstr) {
|
||||||
zvar = input->variable->find(zstr);
|
zvar = input->variable->find(zstr);
|
||||||
if (zvar < 0)
|
if (zvar < 0) error->all(FLERR, "Variable name for fix setvelocity does not exist");
|
||||||
error->all(FLERR, "Variable name for fix setvelocity does not exist");
|
|
||||||
if (input->variable->equalstyle(zvar))
|
if (input->variable->equalstyle(zvar))
|
||||||
zstyle = EQUAL;
|
zstyle = EQUAL;
|
||||||
else if (input->variable->atomstyle(zvar))
|
else if (input->variable->atomstyle(zvar))
|
||||||
@ -171,10 +161,9 @@ void FixSMDSetVel::init() {
|
|||||||
|
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
|
|
||||||
if (iregion >= 0) {
|
if (idregion) {
|
||||||
iregion = domain->find_region(idregion);
|
region = domain->get_region_by_id(idregion);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for fix setvelocity does not exist", idregion);
|
||||||
error->all(FLERR, "Region ID for fix setvelocity does not exist");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xstyle == ATOM || ystyle == ATOM || zstyle == ATOM)
|
if (xstyle == ATOM || ystyle == ATOM || zstyle == ATOM)
|
||||||
@ -189,26 +178,20 @@ void FixSMDSetVel::init() {
|
|||||||
|
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
if (update->whichflag == 2) {
|
if (update->whichflag == 2) {
|
||||||
if (xstyle == EQUAL || xstyle == ATOM)
|
if (xstyle == EQUAL || xstyle == ATOM) flag = 1;
|
||||||
flag = 1;
|
if (ystyle == EQUAL || ystyle == ATOM) flag = 1;
|
||||||
if (ystyle == EQUAL || ystyle == ATOM)
|
if (zstyle == EQUAL || zstyle == ATOM) flag = 1;
|
||||||
flag = 1;
|
if (xstyle == CONSTANT && xvalue != 0.0) flag = 1;
|
||||||
if (zstyle == EQUAL || zstyle == ATOM)
|
if (ystyle == CONSTANT && yvalue != 0.0) flag = 1;
|
||||||
flag = 1;
|
if (zstyle == CONSTANT && zvalue != 0.0) flag = 1;
|
||||||
if (xstyle == CONSTANT && xvalue != 0.0)
|
|
||||||
flag = 1;
|
|
||||||
if (ystyle == CONSTANT && yvalue != 0.0)
|
|
||||||
flag = 1;
|
|
||||||
if (zstyle == CONSTANT && zvalue != 0.0)
|
|
||||||
flag = 1;
|
|
||||||
}
|
}
|
||||||
if (flag)
|
if (flag) error->all(FLERR, "Cannot use non-zero forces in an energy minimization");
|
||||||
error->all(FLERR, "Cannot use non-zero forces in an energy minimization");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixSMDSetVel::setup(int vflag) {
|
void FixSMDSetVel::setup(int vflag)
|
||||||
|
{
|
||||||
if (utils::strmatch(update->integrate_style, "^verlet"))
|
if (utils::strmatch(update->integrate_style, "^verlet"))
|
||||||
post_force(vflag);
|
post_force(vflag);
|
||||||
else
|
else
|
||||||
@ -217,14 +200,15 @@ void FixSMDSetVel::setup(int vflag) {
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixSMDSetVel::min_setup(int vflag) {
|
void FixSMDSetVel::min_setup(int vflag)
|
||||||
|
{
|
||||||
post_force(vflag);
|
post_force(vflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
//void FixSMDSetVel::initial_integrate(int vflag) {
|
void FixSMDSetVel::post_force(int /*vflag*/)
|
||||||
void FixSMDSetVel::post_force(int /*vflag*/) {
|
{
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
double **v = atom->v;
|
double **v = atom->v;
|
||||||
@ -234,11 +218,7 @@ void FixSMDSetVel::post_force(int /*vflag*/) {
|
|||||||
|
|
||||||
// update region if necessary
|
// update region if necessary
|
||||||
|
|
||||||
Region *region = nullptr;
|
if (region) region->prematch();
|
||||||
if (iregion >= 0) {
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
|
||||||
}
|
|
||||||
|
|
||||||
// reallocate sforce array if necessary
|
// reallocate sforce array if necessary
|
||||||
|
|
||||||
@ -254,8 +234,7 @@ void FixSMDSetVel::post_force(int /*vflag*/) {
|
|||||||
if (varflag == CONSTANT) {
|
if (varflag == CONSTANT) {
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (region && !region->match(x[i][0], x[i][1], x[i][2]))
|
if (region && !region->match(x[i][0], x[i][1], x[i][2])) continue;
|
||||||
continue;
|
|
||||||
foriginal[0] += f[i][0];
|
foriginal[0] += f[i][0];
|
||||||
foriginal[1] += f[i][1];
|
foriginal[1] += f[i][1];
|
||||||
foriginal[2] += f[i][2];
|
foriginal[2] += f[i][2];
|
||||||
@ -297,12 +276,9 @@ void FixSMDSetVel::post_force(int /*vflag*/) {
|
|||||||
|
|
||||||
modify->addstep_compute(update->ntimestep + 1);
|
modify->addstep_compute(update->ntimestep + 1);
|
||||||
|
|
||||||
//printf("setting velocity at timestep %d\n", update->ntimestep);
|
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (region && !region->match(x[i][0], x[i][1], x[i][2]))
|
if (region && !region->match(x[i][0], x[i][1], x[i][2])) continue;
|
||||||
continue;
|
|
||||||
foriginal[0] += f[i][0];
|
foriginal[0] += f[i][0];
|
||||||
foriginal[1] += f[i][1];
|
foriginal[1] += f[i][1];
|
||||||
foriginal[2] += f[i][2];
|
foriginal[2] += f[i][2];
|
||||||
@ -329,7 +305,6 @@ void FixSMDSetVel::post_force(int /*vflag*/) {
|
|||||||
vest[i][2] = v[i][2] = zvalue;
|
vest[i][2] = v[i][2] = zvalue;
|
||||||
f[i][2] = 0.0;
|
f[i][2] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,7 +313,8 @@ void FixSMDSetVel::post_force(int /*vflag*/) {
|
|||||||
return components of total force on fix group before force was changed
|
return components of total force on fix group before force was changed
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
double FixSMDSetVel::compute_vector(int n) {
|
double FixSMDSetVel::compute_vector(int n)
|
||||||
|
{
|
||||||
// only sum across procs one time
|
// only sum across procs one time
|
||||||
|
|
||||||
if (force_flag == 0) {
|
if (force_flag == 0) {
|
||||||
@ -352,9 +328,9 @@ double FixSMDSetVel::compute_vector(int n) {
|
|||||||
memory usage of local atom-based array
|
memory usage of local atom-based array
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
double FixSMDSetVel::memory_usage() {
|
double FixSMDSetVel::memory_usage()
|
||||||
|
{
|
||||||
double bytes = 0.0;
|
double bytes = 0.0;
|
||||||
if (varflag == ATOM)
|
if (varflag == ATOM) bytes = atom->nmax * 3 * sizeof(double);
|
||||||
bytes = atom->nmax * 3 * sizeof(double);
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,9 +50,10 @@ class FixSMDSetVel : public Fix {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
double xvalue, yvalue, zvalue;
|
double xvalue, yvalue, zvalue;
|
||||||
int varflag, iregion;
|
int varflag;
|
||||||
char *xstr, *ystr, *zstr;
|
char *xstr, *ystr, *zstr;
|
||||||
char *idregion;
|
char *idregion;
|
||||||
|
class Region *region;
|
||||||
int xvar, yvar, zvar, xstyle, ystyle, zstyle;
|
int xvar, yvar, zvar, xstyle, ystyle, zstyle;
|
||||||
double foriginal[3], foriginal_all[3];
|
double foriginal[3], foriginal_all[3];
|
||||||
int force_flag;
|
int force_flag;
|
||||||
|
|||||||
@ -37,6 +37,7 @@ namespace user_manifold {
|
|||||||
int nparams() override { return NPARAMS; }
|
int nparams() override { return NPARAMS; }
|
||||||
|
|
||||||
void post_param_init() override;
|
void post_param_init() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init_domains();
|
void init_domains();
|
||||||
|
|
||||||
|
|||||||
@ -800,8 +800,7 @@ void PairEDIP::read_file(char *file)
|
|||||||
|
|
||||||
if (nparams == maxparam) {
|
if (nparams == maxparam) {
|
||||||
maxparam += DELTA;
|
maxparam += DELTA;
|
||||||
params = (Param *) memory->srealloc(params,maxparam*sizeof(Param),
|
params = (Param *) memory->srealloc(params, maxparam * sizeof(Param), "pair:params");
|
||||||
"pair:params");
|
|
||||||
|
|
||||||
// make certain all addional allocated storage is initialized
|
// make certain all addional allocated storage is initialized
|
||||||
// to avoid false positives when checking with valgrind
|
// to avoid false positives when checking with valgrind
|
||||||
|
|||||||
@ -58,8 +58,8 @@ class PairSW : public Pair {
|
|||||||
void read_file(char *);
|
void read_file(char *);
|
||||||
virtual void setup_params();
|
virtual void setup_params();
|
||||||
void twobody(Param *, double, double &, int, double &);
|
void twobody(Param *, double, double &, int, double &);
|
||||||
virtual void threebody(Param *, Param *, Param *, double, double, double *, double *, double *, double *,
|
virtual void threebody(Param *, Param *, Param *, double, double, double *, double *, double *,
|
||||||
int, double &);
|
double *, int, double &);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LAMMPS_NS
|
} // namespace LAMMPS_NS
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -40,9 +39,9 @@
|
|||||||
#include "region.h"
|
#include "region.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
@ -51,11 +50,10 @@ using namespace FixConst;
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixAtomSwap::FixAtomSwap(LAMMPS *lmp, int narg, char **arg) :
|
FixAtomSwap::FixAtomSwap(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg),
|
Fix(lmp, narg, arg), region(nullptr), idregion(nullptr), type_list(nullptr), mu(nullptr),
|
||||||
idregion(nullptr), type_list(nullptr), mu(nullptr), qtype(nullptr),
|
qtype(nullptr), sqrt_mass_ratio(nullptr), local_swap_iatom_list(nullptr),
|
||||||
sqrt_mass_ratio(nullptr), local_swap_iatom_list(nullptr),
|
local_swap_jatom_list(nullptr), local_swap_atom_list(nullptr), random_equal(nullptr),
|
||||||
local_swap_jatom_list(nullptr), local_swap_atom_list(nullptr),
|
random_unequal(nullptr), c_pe(nullptr)
|
||||||
random_equal(nullptr), random_unequal(nullptr), c_pe(nullptr)
|
|
||||||
{
|
{
|
||||||
if (narg < 10) error->all(FLERR, "Illegal fix atom/swap command");
|
if (narg < 10) error->all(FLERR, "Illegal fix atom/swap command");
|
||||||
|
|
||||||
@ -115,9 +113,10 @@ FixAtomSwap::FixAtomSwap(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
// set comm size needed by this Fix
|
// set comm size needed by this Fix
|
||||||
|
|
||||||
if (atom->q_flag) comm_forward = 2;
|
if (atom->q_flag)
|
||||||
else comm_forward = 1;
|
comm_forward = 2;
|
||||||
|
else
|
||||||
|
comm_forward = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -130,7 +129,7 @@ FixAtomSwap::~FixAtomSwap()
|
|||||||
memory->destroy(sqrt_mass_ratio);
|
memory->destroy(sqrt_mass_ratio);
|
||||||
memory->destroy(local_swap_iatom_list);
|
memory->destroy(local_swap_iatom_list);
|
||||||
memory->destroy(local_swap_jatom_list);
|
memory->destroy(local_swap_jatom_list);
|
||||||
if (regionflag) delete [] idregion;
|
delete[] idregion;
|
||||||
delete random_equal;
|
delete random_equal;
|
||||||
delete random_unequal;
|
delete random_unequal;
|
||||||
}
|
}
|
||||||
@ -143,22 +142,18 @@ void FixAtomSwap::options(int narg, char **arg)
|
|||||||
{
|
{
|
||||||
if (narg < 0) error->all(FLERR, "Illegal fix atom/swap command");
|
if (narg < 0) error->all(FLERR, "Illegal fix atom/swap command");
|
||||||
|
|
||||||
regionflag = 0;
|
|
||||||
ke_flag = 1;
|
ke_flag = 1;
|
||||||
semi_grand_flag = 0;
|
semi_grand_flag = 0;
|
||||||
nswaptypes = 0;
|
nswaptypes = 0;
|
||||||
nmutypes = 0;
|
nmutypes = 0;
|
||||||
iregion = -1;
|
|
||||||
|
|
||||||
int iarg = 0;
|
int iarg = 0;
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg], "region") == 0) {
|
if (strcmp(arg[iarg], "region") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix atom/swap command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix atom/swap command");
|
||||||
iregion = domain->find_region(arg[iarg+1]);
|
region = domain->get_region_by_id(arg[iarg + 1]);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for fix atom/swap does not exist", arg[iarg + 1]);
|
||||||
error->all(FLERR,"Region ID for fix atom/swap does not exist");
|
|
||||||
idregion = utils::strdup(arg[iarg + 1]);
|
idregion = utils::strdup(arg[iarg + 1]);
|
||||||
regionflag = 1;
|
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg], "ke") == 0) {
|
} else if (strcmp(arg[iarg], "ke") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix atom/swap command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix atom/swap command");
|
||||||
@ -188,7 +183,8 @@ void FixAtomSwap::options(int narg, char **arg)
|
|||||||
mu[nmutypes] = utils::numeric(FLERR, arg[iarg], false, lmp);
|
mu[nmutypes] = utils::numeric(FLERR, arg[iarg], false, lmp);
|
||||||
iarg++;
|
iarg++;
|
||||||
}
|
}
|
||||||
} else error->all(FLERR,"Illegal fix atom/swap command");
|
} else
|
||||||
|
error->all(FLERR, "Illegal fix atom/swap command");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,14 +201,11 @@ int FixAtomSwap::setmask()
|
|||||||
|
|
||||||
void FixAtomSwap::init()
|
void FixAtomSwap::init()
|
||||||
{
|
{
|
||||||
auto id_pe = (char *) "thermo_pe";
|
c_pe = modify->get_compute_by_id("thermo_pe");
|
||||||
int ipe = modify->find_compute(id_pe);
|
|
||||||
c_pe = modify->compute[ipe];
|
|
||||||
|
|
||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
|
|
||||||
if (nswaptypes < 2)
|
if (nswaptypes < 2) error->all(FLERR, "Must specify at least 2 types in fix atom/swap command");
|
||||||
error->all(FLERR,"Must specify at least 2 types in fix atom/swap command");
|
|
||||||
|
|
||||||
if (semi_grand_flag) {
|
if (semi_grand_flag) {
|
||||||
if (nswaptypes != nmutypes)
|
if (nswaptypes != nmutypes)
|
||||||
@ -224,6 +217,13 @@ void FixAtomSwap::init()
|
|||||||
error->all(FLERR, "Mu not allowed when not using semi-grand in fix atom/swap command");
|
error->all(FLERR, "Mu not allowed when not using semi-grand in fix atom/swap command");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set index and check validity of region
|
||||||
|
|
||||||
|
if (idregion) {
|
||||||
|
region = domain->get_region_by_id(idregion);
|
||||||
|
if (!region) error->all(FLERR, "Region {} for fix setforce does not exist", idregion);
|
||||||
|
}
|
||||||
|
|
||||||
for (int iswaptype = 0; iswaptype < nswaptypes; iswaptype++)
|
for (int iswaptype = 0; iswaptype < nswaptypes; iswaptype++)
|
||||||
if (type_list[iswaptype] <= 0 || type_list[iswaptype] > atom->ntypes)
|
if (type_list[iswaptype] <= 0 || type_list[iswaptype] > atom->ntypes)
|
||||||
error->all(FLERR, "Invalid atom type in fix atom/swap command");
|
error->all(FLERR, "Invalid atom type in fix atom/swap command");
|
||||||
@ -249,7 +249,9 @@ void FixAtomSwap::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MPI_Allreduce(&first, &firstall, 1, MPI_INT, MPI_MIN, world);
|
MPI_Allreduce(&first, &firstall, 1, MPI_INT, MPI_MIN, world);
|
||||||
if (firstall) error->all(FLERR,"At least one atom of each swapped type must be present to define charges.");
|
if (firstall)
|
||||||
|
error->all(FLERR,
|
||||||
|
"At least one atom of each swapped type must be present to define charges.");
|
||||||
if (first) qtype[iswaptype] = -DBL_MAX;
|
if (first) qtype[iswaptype] = -DBL_MAX;
|
||||||
MPI_Allreduce(&qtype[iswaptype], &qmax, 1, MPI_DOUBLE, MPI_MAX, world);
|
MPI_Allreduce(&qtype[iswaptype], &qmax, 1, MPI_DOUBLE, MPI_MAX, world);
|
||||||
if (first) qtype[iswaptype] = DBL_MAX;
|
if (first) qtype[iswaptype] = DBL_MAX;
|
||||||
@ -288,8 +290,7 @@ void FixAtomSwap::init()
|
|||||||
int flagall;
|
int flagall;
|
||||||
MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world);
|
MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world);
|
||||||
|
|
||||||
if (flagall)
|
if (flagall) error->all(FLERR, "Cannot do atom/swap on atoms in atom_modify first group");
|
||||||
error->all(FLERR,"Cannot do atom/swap on atoms in atom_modify first group");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,8 +390,8 @@ int FixAtomSwap::attempt_semi_grand()
|
|||||||
int success = 0;
|
int success = 0;
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
if (random_unequal->uniform() <
|
if (random_unequal->uniform() <
|
||||||
exp(beta*(energy_before - energy_after
|
exp(beta * (energy_before - energy_after + mu[jtype] - mu[itype])))
|
||||||
+ mu[jtype] - mu[itype]))) success = 1;
|
success = 1;
|
||||||
|
|
||||||
int success_all = 0;
|
int success_all = 0;
|
||||||
MPI_Allreduce(&success, &success_all, 1, MPI_INT, MPI_MAX, world);
|
MPI_Allreduce(&success, &success_all, 1, MPI_INT, MPI_MAX, world);
|
||||||
@ -474,8 +475,7 @@ int FixAtomSwap::attempt_swap()
|
|||||||
// swap accepted, return 1
|
// swap accepted, return 1
|
||||||
// if ke_flag, rescale atom velocities
|
// if ke_flag, rescale atom velocities
|
||||||
|
|
||||||
if (random_equal->uniform() <
|
if (random_equal->uniform() < exp(beta * (energy_before - energy_after))) {
|
||||||
exp(beta*(energy_before - energy_after))) {
|
|
||||||
update_swap_atoms_list();
|
update_swap_atoms_list();
|
||||||
if (ke_flag) {
|
if (ke_flag) {
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
@ -547,8 +547,7 @@ int FixAtomSwap::pick_semi_grand_atom()
|
|||||||
{
|
{
|
||||||
int i = -1;
|
int i = -1;
|
||||||
int iwhichglobal = static_cast<int>(nswap * random_equal->uniform());
|
int iwhichglobal = static_cast<int>(nswap * random_equal->uniform());
|
||||||
if ((iwhichglobal >= nswap_before) &&
|
if ((iwhichglobal >= nswap_before) && (iwhichglobal < nswap_before + nswap_local)) {
|
||||||
(iwhichglobal < nswap_before + nswap_local)) {
|
|
||||||
int iwhichlocal = iwhichglobal - nswap_before;
|
int iwhichlocal = iwhichglobal - nswap_before;
|
||||||
i = local_swap_atom_list[iwhichlocal];
|
i = local_swap_atom_list[iwhichlocal];
|
||||||
}
|
}
|
||||||
@ -563,8 +562,7 @@ int FixAtomSwap::pick_i_swap_atom()
|
|||||||
{
|
{
|
||||||
int i = -1;
|
int i = -1;
|
||||||
int iwhichglobal = static_cast<int>(niswap * random_equal->uniform());
|
int iwhichglobal = static_cast<int>(niswap * random_equal->uniform());
|
||||||
if ((iwhichglobal >= niswap_before) &&
|
if ((iwhichglobal >= niswap_before) && (iwhichglobal < niswap_before + niswap_local)) {
|
||||||
(iwhichglobal < niswap_before + niswap_local)) {
|
|
||||||
int iwhichlocal = iwhichglobal - niswap_before;
|
int iwhichlocal = iwhichglobal - niswap_before;
|
||||||
i = local_swap_iatom_list[iwhichlocal];
|
i = local_swap_iatom_list[iwhichlocal];
|
||||||
}
|
}
|
||||||
@ -579,8 +577,7 @@ int FixAtomSwap::pick_j_swap_atom()
|
|||||||
{
|
{
|
||||||
int j = -1;
|
int j = -1;
|
||||||
int jwhichglobal = static_cast<int>(njswap * random_equal->uniform());
|
int jwhichglobal = static_cast<int>(njswap * random_equal->uniform());
|
||||||
if ((jwhichglobal >= njswap_before) &&
|
if ((jwhichglobal >= njswap_before) && (jwhichglobal < njswap_before + njswap_local)) {
|
||||||
(jwhichglobal < njswap_before + njswap_local)) {
|
|
||||||
int jwhichlocal = jwhichglobal - njswap_before;
|
int jwhichlocal = jwhichglobal - njswap_before;
|
||||||
j = local_swap_jatom_list[jwhichlocal];
|
j = local_swap_jatom_list[jwhichlocal];
|
||||||
}
|
}
|
||||||
@ -600,16 +597,15 @@ void FixAtomSwap::update_semi_grand_atoms_list()
|
|||||||
if (atom->nmax > atom_swap_nmax) {
|
if (atom->nmax > atom_swap_nmax) {
|
||||||
memory->sfree(local_swap_atom_list);
|
memory->sfree(local_swap_atom_list);
|
||||||
atom_swap_nmax = atom->nmax;
|
atom_swap_nmax = atom->nmax;
|
||||||
local_swap_atom_list = (int *) memory->smalloc(atom_swap_nmax*sizeof(int),
|
local_swap_atom_list =
|
||||||
"MCSWAP:local_swap_atom_list");
|
(int *) memory->smalloc(atom_swap_nmax * sizeof(int), "MCSWAP:local_swap_atom_list");
|
||||||
}
|
}
|
||||||
|
|
||||||
nswap_local = 0;
|
nswap_local = 0;
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]) == 1) {
|
if (region->match(x[i][0], x[i][1], x[i][2]) == 1) {
|
||||||
if (atom->mask[i] & groupbit) {
|
if (atom->mask[i] & groupbit) {
|
||||||
int itype = atom->type[i];
|
int itype = atom->type[i];
|
||||||
int iswaptype;
|
int iswaptype;
|
||||||
@ -641,7 +637,6 @@ void FixAtomSwap::update_semi_grand_atoms_list()
|
|||||||
nswap_before -= nswap_local;
|
nswap_before -= nswap_local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
update the list of gas atoms
|
update the list of gas atoms
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
@ -656,19 +651,19 @@ void FixAtomSwap::update_swap_atoms_list()
|
|||||||
memory->sfree(local_swap_iatom_list);
|
memory->sfree(local_swap_iatom_list);
|
||||||
memory->sfree(local_swap_jatom_list);
|
memory->sfree(local_swap_jatom_list);
|
||||||
atom_swap_nmax = atom->nmax;
|
atom_swap_nmax = atom->nmax;
|
||||||
local_swap_iatom_list = (int *) memory->smalloc(atom_swap_nmax*sizeof(int),
|
local_swap_iatom_list =
|
||||||
"MCSWAP:local_swap_iatom_list");
|
(int *) memory->smalloc(atom_swap_nmax * sizeof(int), "MCSWAP:local_swap_iatom_list");
|
||||||
local_swap_jatom_list = (int *) memory->smalloc(atom_swap_nmax*sizeof(int),
|
local_swap_jatom_list =
|
||||||
"MCSWAP:local_swap_jatom_list");
|
(int *) memory->smalloc(atom_swap_nmax * sizeof(int), "MCSWAP:local_swap_jatom_list");
|
||||||
}
|
}
|
||||||
|
|
||||||
niswap_local = 0;
|
niswap_local = 0;
|
||||||
njswap_local = 0;
|
njswap_local = 0;
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]) == 1) {
|
if (region->match(x[i][0], x[i][1], x[i][2]) == 1) {
|
||||||
if (atom->mask[i] & groupbit) {
|
if (atom->mask[i] & groupbit) {
|
||||||
if (type[i] == type_list[0]) {
|
if (type[i] == type_list[0]) {
|
||||||
local_swap_iatom_list[niswap_local] = i;
|
local_swap_iatom_list[niswap_local] = i;
|
||||||
@ -749,8 +744,7 @@ void FixAtomSwap::unpack_forward_comm(int n, int first, double *buf)
|
|||||||
q[i] = buf[m++];
|
q[i] = buf[m++];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = first; i < last; i++)
|
for (i = first; i < last; i++) type[i] = static_cast<int>(buf[m++]);
|
||||||
type[i] = static_cast<int> (buf[m++]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,8 +49,7 @@ class FixAtomSwap : public Fix {
|
|||||||
int nswap; // # of swap atoms on all procs
|
int nswap; // # of swap atoms on all procs
|
||||||
int nswap_local; // # of swap atoms on this proc
|
int nswap_local; // # of swap atoms on this proc
|
||||||
int nswap_before; // # of swap atoms on procs < this proc
|
int nswap_before; // # of swap atoms on procs < this proc
|
||||||
int regionflag; // 0 = anywhere in box, 1 = specific region
|
class Region *region; // swap region
|
||||||
int iregion; // swap region
|
|
||||||
char *idregion; // swap region id
|
char *idregion; // swap region id
|
||||||
|
|
||||||
int nswaptypes, nmutypes;
|
int nswaptypes, nmutypes;
|
||||||
|
|||||||
@ -68,7 +68,7 @@ enum{NONE,MOVEATOM,MOVEMOL}; // movemode
|
|||||||
|
|
||||||
FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) :
|
FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg),
|
Fix(lmp, narg, arg),
|
||||||
idregion(nullptr), full_flag(false), ngroups(0), groupstrings(nullptr), ngrouptypes(0),
|
region(nullptr), idregion(nullptr), full_flag(false), groupstrings(nullptr),
|
||||||
grouptypestrings(nullptr), grouptypebits(nullptr), grouptypes(nullptr), local_gas_list(nullptr),
|
grouptypestrings(nullptr), grouptypebits(nullptr), grouptypes(nullptr), local_gas_list(nullptr),
|
||||||
molcoords(nullptr), molq(nullptr), molimage(nullptr), random_equal(nullptr), random_unequal(nullptr),
|
molcoords(nullptr), molq(nullptr), molimage(nullptr), random_equal(nullptr), random_unequal(nullptr),
|
||||||
fixrigid(nullptr), fixshake(nullptr), idrigid(nullptr), idshake(nullptr)
|
fixrigid(nullptr), fixshake(nullptr), idrigid(nullptr), idshake(nullptr)
|
||||||
@ -87,6 +87,9 @@ FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
restart_global = 1;
|
restart_global = 1;
|
||||||
time_depend = 1;
|
time_depend = 1;
|
||||||
|
|
||||||
|
ngroups = 0;
|
||||||
|
ngrouptypes = 0;
|
||||||
|
|
||||||
// required args
|
// required args
|
||||||
|
|
||||||
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
|
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
|
||||||
@ -122,18 +125,18 @@ FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
region_xlo = region_xhi = region_ylo = region_yhi =
|
region_xlo = region_xhi = region_ylo = region_yhi =
|
||||||
region_zlo = region_zhi = 0.0;
|
region_zlo = region_zhi = 0.0;
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
if (domain->regions[iregion]->bboxflag == 0)
|
if (region->bboxflag == 0)
|
||||||
error->all(FLERR,"Fix gcmc region does not support a bounding box");
|
error->all(FLERR,"Fix gcmc region does not support a bounding box");
|
||||||
if (domain->regions[iregion]->dynamic_check())
|
if (region->dynamic_check())
|
||||||
error->all(FLERR,"Fix gcmc region cannot be dynamic");
|
error->all(FLERR,"Fix gcmc region cannot be dynamic");
|
||||||
|
|
||||||
region_xlo = domain->regions[iregion]->extent_xlo;
|
region_xlo = region->extent_xlo;
|
||||||
region_xhi = domain->regions[iregion]->extent_xhi;
|
region_xhi = region->extent_xhi;
|
||||||
region_ylo = domain->regions[iregion]->extent_ylo;
|
region_ylo = region->extent_ylo;
|
||||||
region_yhi = domain->regions[iregion]->extent_yhi;
|
region_yhi = region->extent_yhi;
|
||||||
region_zlo = domain->regions[iregion]->extent_zlo;
|
region_zlo = region->extent_zlo;
|
||||||
region_zhi = domain->regions[iregion]->extent_zhi;
|
region_zhi = region->extent_zhi;
|
||||||
|
|
||||||
if (region_xlo < domain->boxlo[0] || region_xhi > domain->boxhi[0] ||
|
if (region_xlo < domain->boxlo[0] || region_xhi > domain->boxhi[0] ||
|
||||||
region_ylo < domain->boxlo[1] || region_yhi > domain->boxhi[1] ||
|
region_ylo < domain->boxlo[1] || region_yhi > domain->boxhi[1] ||
|
||||||
@ -149,15 +152,14 @@ FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
if (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) != 0)
|
if (region->match(coord[0],coord[1],coord[2]) != 0)
|
||||||
inside++;
|
inside++;
|
||||||
}
|
}
|
||||||
|
|
||||||
double max_region_volume = (region_xhi - region_xlo) *
|
double max_region_volume = (region_xhi - region_xlo) *
|
||||||
(region_yhi - region_ylo) * (region_zhi - region_zlo);
|
(region_yhi - region_ylo) * (region_zhi - region_zlo);
|
||||||
|
|
||||||
region_volume = max_region_volume*static_cast<double> (inside)/
|
region_volume = max_region_volume * static_cast<double>(inside) / static_cast<double>(attempts);
|
||||||
static_cast<double> (attempts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// error check and further setup for exchmode = EXCHMOL
|
// error check and further setup for exchmode = EXCHMOL
|
||||||
@ -241,8 +243,6 @@ void FixGCMC::options(int narg, char **arg)
|
|||||||
pmolrotate = 0.0;
|
pmolrotate = 0.0;
|
||||||
pmctot = 0.0;
|
pmctot = 0.0;
|
||||||
max_rotation_angle = 10*MY_PI/180;
|
max_rotation_angle = 10*MY_PI/180;
|
||||||
regionflag = 0;
|
|
||||||
iregion = -1;
|
|
||||||
region_volume = 0;
|
region_volume = 0;
|
||||||
max_region_attempts = 1000;
|
max_region_attempts = 1000;
|
||||||
molecule_group = 0;
|
molecule_group = 0;
|
||||||
@ -300,11 +300,10 @@ void FixGCMC::options(int narg, char **arg)
|
|||||||
iarg += 4;
|
iarg += 4;
|
||||||
} else if (strcmp(arg[iarg],"region") == 0) {
|
} else if (strcmp(arg[iarg],"region") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
|
||||||
iregion = domain->find_region(arg[iarg+1]);
|
region = domain->get_region_by_id(arg[iarg+1]);
|
||||||
if (iregion == -1)
|
if (!region)
|
||||||
error->all(FLERR,"Region ID for fix gcmc does not exist");
|
error->all(FLERR,"Region {} for fix gcmc does not exist",arg[iarg+1]);
|
||||||
idregion = utils::strdup(arg[iarg+1]);
|
idregion = utils::strdup(arg[iarg+1]);
|
||||||
regionflag = 1;
|
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"maxangle") == 0) {
|
} else if (strcmp(arg[iarg],"maxangle") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
|
||||||
@ -397,7 +396,7 @@ void FixGCMC::options(int narg, char **arg)
|
|||||||
|
|
||||||
FixGCMC::~FixGCMC()
|
FixGCMC::~FixGCMC()
|
||||||
{
|
{
|
||||||
if (regionflag) delete [] idregion;
|
delete[] idregion;
|
||||||
delete random_equal;
|
delete random_equal;
|
||||||
delete random_unequal;
|
delete random_unequal;
|
||||||
|
|
||||||
@ -443,6 +442,13 @@ int FixGCMC::setmask()
|
|||||||
void FixGCMC::init()
|
void FixGCMC::init()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// set index and check validity of region
|
||||||
|
|
||||||
|
if (idregion) {
|
||||||
|
region = domain->get_region_by_id(idregion);
|
||||||
|
if (!region) error->all(FLERR, "Region {} for fix gcmc does not exist", idregion);
|
||||||
|
}
|
||||||
|
|
||||||
triclinic = domain->triclinic;
|
triclinic = domain->triclinic;
|
||||||
|
|
||||||
// set probabilities for MC moves
|
// set probabilities for MC moves
|
||||||
@ -719,7 +725,7 @@ void FixGCMC::pre_exchange()
|
|||||||
subhi = domain->subhi;
|
subhi = domain->subhi;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regionflag) volume = region_volume;
|
if (region) volume = region_volume;
|
||||||
else volume = domain->xprd * domain->yprd * domain->zprd;
|
else volume = domain->xprd * domain->yprd * domain->zprd;
|
||||||
|
|
||||||
if (triclinic) domain->x2lamda(atom->nlocal);
|
if (triclinic) domain->x2lamda(atom->nlocal);
|
||||||
@ -801,8 +807,7 @@ void FixGCMC::attempt_atomic_translation()
|
|||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double energy_before = energy(i,ngcmc_type,-1,x[i]);
|
double energy_before = energy(i,ngcmc_type,-1,x[i]);
|
||||||
if (overlap_flag && energy_before > MAXENERGYTEST)
|
if (overlap_flag && energy_before > MAXENERGYTEST)
|
||||||
error->warning(FLERR,"Energy of old configuration in "
|
error->warning(FLERR,"Energy of old configuration in fix gcmc is > MAXENERGYTEST.");
|
||||||
"fix gcmc is > MAXENERGYTEST.");
|
|
||||||
double rsq = 1.1;
|
double rsq = 1.1;
|
||||||
double rx,ry,rz;
|
double rx,ry,rz;
|
||||||
rx = ry = rz = 0.0;
|
rx = ry = rz = 0.0;
|
||||||
@ -816,8 +821,8 @@ void FixGCMC::attempt_atomic_translation()
|
|||||||
coord[0] = x[i][0] + displace*rx;
|
coord[0] = x[i][0] + displace*rx;
|
||||||
coord[1] = x[i][1] + displace*ry;
|
coord[1] = x[i][1] + displace*ry;
|
||||||
coord[2] = x[i][2] + displace*rz;
|
coord[2] = x[i][2] + displace*rz;
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
|
while (region->match(coord[0],coord[1],coord[2]) == 0) {
|
||||||
rsq = 1.1;
|
rsq = 1.1;
|
||||||
while (rsq > 1.0) {
|
while (rsq > 1.0) {
|
||||||
rx = 2*random_unequal->uniform() - 1.0;
|
rx = 2*random_unequal->uniform() - 1.0;
|
||||||
@ -913,12 +918,12 @@ void FixGCMC::attempt_atomic_insertion()
|
|||||||
// pick coordinates for insertion point
|
// pick coordinates for insertion point
|
||||||
|
|
||||||
double coord[3];
|
double coord[3];
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int region_attempt = 0;
|
int region_attempt = 0;
|
||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
|
while (region->match(coord[0],coord[1],coord[2]) == 0) {
|
||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
@ -1043,7 +1048,7 @@ void FixGCMC::attempt_molecule_translation()
|
|||||||
com_displace[1] = displace*ry;
|
com_displace[1] = displace*ry;
|
||||||
com_displace[2] = displace*rz;
|
com_displace[2] = displace*rz;
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
for (int i = 0; i < atom->nlocal; i++) {
|
for (int i = 0; i < atom->nlocal; i++) {
|
||||||
if (atom->molecule[i] == translation_molecule) {
|
if (atom->molecule[i] == translation_molecule) {
|
||||||
@ -1058,7 +1063,7 @@ void FixGCMC::attempt_molecule_translation()
|
|||||||
coord[0] = com[0] + displace*rx;
|
coord[0] = com[0] + displace*rx;
|
||||||
coord[1] = com[1] + displace*ry;
|
coord[1] = com[1] + displace*ry;
|
||||||
coord[2] = com[2] + displace*rz;
|
coord[2] = com[2] + displace*rz;
|
||||||
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
|
while (region->match(coord[0],coord[1],coord[2]) == 0) {
|
||||||
rsq = 1.1;
|
rsq = 1.1;
|
||||||
while (rsq > 1.0) {
|
while (rsq > 1.0) {
|
||||||
rx = 2*random_equal->uniform() - 1.0;
|
rx = 2*random_equal->uniform() - 1.0;
|
||||||
@ -1266,7 +1271,7 @@ void FixGCMC::attempt_molecule_insertion()
|
|||||||
if (ngas >= max_ngas) return;
|
if (ngas >= max_ngas) return;
|
||||||
|
|
||||||
double com_coord[3];
|
double com_coord[3];
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int region_attempt = 0;
|
int region_attempt = 0;
|
||||||
com_coord[0] = region_xlo + random_equal->uniform() *
|
com_coord[0] = region_xlo + random_equal->uniform() *
|
||||||
(region_xhi-region_xlo);
|
(region_xhi-region_xlo);
|
||||||
@ -1274,7 +1279,7 @@ void FixGCMC::attempt_molecule_insertion()
|
|||||||
(region_yhi-region_ylo);
|
(region_yhi-region_ylo);
|
||||||
com_coord[2] = region_zlo + random_equal->uniform() *
|
com_coord[2] = region_zlo + random_equal->uniform() *
|
||||||
(region_zhi-region_zlo);
|
(region_zhi-region_zlo);
|
||||||
while (domain->regions[iregion]->match(com_coord[0],com_coord[1],
|
while (region->match(com_coord[0],com_coord[1],
|
||||||
com_coord[2]) == 0) {
|
com_coord[2]) == 0) {
|
||||||
com_coord[0] = region_xlo + random_equal->uniform() *
|
com_coord[0] = region_xlo + random_equal->uniform() *
|
||||||
(region_xhi-region_xlo);
|
(region_xhi-region_xlo);
|
||||||
@ -1485,8 +1490,8 @@ void FixGCMC::attempt_atomic_translation_full()
|
|||||||
coord[0] = x[i][0] + displace*rx;
|
coord[0] = x[i][0] + displace*rx;
|
||||||
coord[1] = x[i][1] + displace*ry;
|
coord[1] = x[i][1] + displace*ry;
|
||||||
coord[2] = x[i][2] + displace*rz;
|
coord[2] = x[i][2] + displace*rz;
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
|
while (region->match(coord[0],coord[1],coord[2]) == 0) {
|
||||||
rsq = 1.1;
|
rsq = 1.1;
|
||||||
while (rsq > 1.0) {
|
while (rsq > 1.0) {
|
||||||
rx = 2*random_unequal->uniform() - 1.0;
|
rx = 2*random_unequal->uniform() - 1.0;
|
||||||
@ -1602,12 +1607,12 @@ void FixGCMC::attempt_atomic_insertion_full()
|
|||||||
double energy_before = energy_stored;
|
double energy_before = energy_stored;
|
||||||
|
|
||||||
double coord[3];
|
double coord[3];
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int region_attempt = 0;
|
int region_attempt = 0;
|
||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
|
while (region->match(coord[0],coord[1],coord[2]) == 0) {
|
||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
@ -1726,7 +1731,7 @@ void FixGCMC::attempt_molecule_translation_full()
|
|||||||
com_displace[1] = displace*ry;
|
com_displace[1] = displace*ry;
|
||||||
com_displace[2] = displace*rz;
|
com_displace[2] = displace*rz;
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
for (int i = 0; i < atom->nlocal; i++) {
|
for (int i = 0; i < atom->nlocal; i++) {
|
||||||
if (atom->molecule[i] == translation_molecule) {
|
if (atom->molecule[i] == translation_molecule) {
|
||||||
@ -1741,7 +1746,7 @@ void FixGCMC::attempt_molecule_translation_full()
|
|||||||
coord[0] = com[0] + displace*rx;
|
coord[0] = com[0] + displace*rx;
|
||||||
coord[1] = com[1] + displace*ry;
|
coord[1] = com[1] + displace*ry;
|
||||||
coord[2] = com[2] + displace*rz;
|
coord[2] = com[2] + displace*rz;
|
||||||
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
|
while (region->match(coord[0],coord[1],coord[2]) == 0) {
|
||||||
rsq = 1.1;
|
rsq = 1.1;
|
||||||
while (rsq > 1.0) {
|
while (rsq > 1.0) {
|
||||||
rx = 2*random_equal->uniform() - 1.0;
|
rx = 2*random_equal->uniform() - 1.0;
|
||||||
@ -1998,7 +2003,7 @@ void FixGCMC::attempt_molecule_insertion_full()
|
|||||||
int nlocalprev = atom->nlocal;
|
int nlocalprev = atom->nlocal;
|
||||||
|
|
||||||
double com_coord[3];
|
double com_coord[3];
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int region_attempt = 0;
|
int region_attempt = 0;
|
||||||
com_coord[0] = region_xlo + random_equal->uniform() *
|
com_coord[0] = region_xlo + random_equal->uniform() *
|
||||||
(region_xhi-region_xlo);
|
(region_xhi-region_xlo);
|
||||||
@ -2006,7 +2011,7 @@ void FixGCMC::attempt_molecule_insertion_full()
|
|||||||
(region_yhi-region_ylo);
|
(region_yhi-region_ylo);
|
||||||
com_coord[2] = region_zlo + random_equal->uniform() *
|
com_coord[2] = region_zlo + random_equal->uniform() *
|
||||||
(region_zhi-region_zlo);
|
(region_zhi-region_zlo);
|
||||||
while (domain->regions[iregion]->match(com_coord[0],com_coord[1],
|
while (region->match(com_coord[0],com_coord[1],
|
||||||
com_coord[2]) == 0) {
|
com_coord[2]) == 0) {
|
||||||
com_coord[0] = region_xlo + random_equal->uniform() *
|
com_coord[0] = region_xlo + random_equal->uniform() *
|
||||||
(region_xhi-region_xlo);
|
(region_xhi-region_xlo);
|
||||||
@ -2408,7 +2413,7 @@ void FixGCMC::update_gas_atoms_list()
|
|||||||
|
|
||||||
ngas_local = 0;
|
ngas_local = 0;
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
|
|
||||||
if (exchmode == EXCHMOL || movemode == MOVEMOL) {
|
if (exchmode == EXCHMOL || movemode == MOVEMOL) {
|
||||||
|
|
||||||
@ -2441,7 +2446,7 @@ void FixGCMC::update_gas_atoms_list()
|
|||||||
|
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (domain->regions[iregion]->match(comx[molecule[i]],
|
if (region->match(comx[molecule[i]],
|
||||||
comy[molecule[i]],comz[molecule[i]]) == 1) {
|
comy[molecule[i]],comz[molecule[i]]) == 1) {
|
||||||
local_gas_list[ngas_local] = i;
|
local_gas_list[ngas_local] = i;
|
||||||
ngas_local++;
|
ngas_local++;
|
||||||
@ -2454,7 +2459,7 @@ void FixGCMC::update_gas_atoms_list()
|
|||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]) == 1) {
|
if (region->match(x[i][0],x[i][1],x[i][2]) == 1) {
|
||||||
local_gas_list[ngas_local] = i;
|
local_gas_list[ngas_local] = i;
|
||||||
ngas_local++;
|
ngas_local++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,8 +70,7 @@ class FixGCMC : public Fix {
|
|||||||
int ngas_before; // # of gas atoms on procs < this proc
|
int ngas_before; // # of gas atoms on procs < this proc
|
||||||
int exchmode; // exchange ATOM or MOLECULE
|
int exchmode; // exchange ATOM or MOLECULE
|
||||||
int movemode; // move ATOM or MOLECULE
|
int movemode; // move ATOM or MOLECULE
|
||||||
int regionflag; // 0 = anywhere in box, 1 = specific region
|
class Region *region; // gcmc region
|
||||||
int iregion; // gcmc region
|
|
||||||
char *idregion; // gcmc region id
|
char *idregion; // gcmc region id
|
||||||
bool pressure_flag; // true if user specified reservoir pressure
|
bool pressure_flag; // true if user specified reservoir pressure
|
||||||
bool charge_flag; // true if user specified atomic charge
|
bool charge_flag; // true if user specified atomic charge
|
||||||
|
|||||||
@ -46,7 +46,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
@ -59,8 +58,8 @@ enum{EXCHATOM,EXCHMOL}; // exchmode
|
|||||||
|
|
||||||
FixWidom::FixWidom(LAMMPS *lmp, int narg, char **arg) :
|
FixWidom::FixWidom(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Fix(lmp, narg, arg),
|
Fix(lmp, narg, arg),
|
||||||
idregion(nullptr), full_flag(false), local_gas_list(nullptr), molcoords(nullptr),
|
region(nullptr), idregion(nullptr), full_flag(false), local_gas_list(nullptr),
|
||||||
molq(nullptr), molimage(nullptr), random_equal(nullptr)
|
molcoords(nullptr),molq(nullptr), molimage(nullptr), random_equal(nullptr)
|
||||||
{
|
{
|
||||||
if (narg < 8) error->all(FLERR,"Illegal fix widom command");
|
if (narg < 8) error->all(FLERR,"Illegal fix widom command");
|
||||||
|
|
||||||
@ -76,8 +75,6 @@ FixWidom::FixWidom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
restart_global = 1;
|
restart_global = 1;
|
||||||
time_depend = 1;
|
time_depend = 1;
|
||||||
|
|
||||||
//ave_widom_chemical_potential = 0;
|
|
||||||
|
|
||||||
// required args
|
// required args
|
||||||
|
|
||||||
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
|
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
|
||||||
@ -104,18 +101,18 @@ FixWidom::FixWidom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
region_xlo = region_xhi = region_ylo = region_yhi =
|
region_xlo = region_xhi = region_ylo = region_yhi =
|
||||||
region_zlo = region_zhi = 0.0;
|
region_zlo = region_zhi = 0.0;
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
if (domain->regions[iregion]->bboxflag == 0)
|
if (region->bboxflag == 0)
|
||||||
error->all(FLERR,"Fix widom region does not support a bounding box");
|
error->all(FLERR,"Fix widom region does not support a bounding box");
|
||||||
if (domain->regions[iregion]->dynamic_check())
|
if (region->dynamic_check())
|
||||||
error->all(FLERR,"Fix widom region cannot be dynamic");
|
error->all(FLERR,"Fix widom region cannot be dynamic");
|
||||||
|
|
||||||
region_xlo = domain->regions[iregion]->extent_xlo;
|
region_xlo = region->extent_xlo;
|
||||||
region_xhi = domain->regions[iregion]->extent_xhi;
|
region_xhi = region->extent_xhi;
|
||||||
region_ylo = domain->regions[iregion]->extent_ylo;
|
region_ylo = region->extent_ylo;
|
||||||
region_yhi = domain->regions[iregion]->extent_yhi;
|
region_yhi = region->extent_yhi;
|
||||||
region_zlo = domain->regions[iregion]->extent_zlo;
|
region_zlo = region->extent_zlo;
|
||||||
region_zhi = domain->regions[iregion]->extent_zhi;
|
region_zhi = region->extent_zhi;
|
||||||
|
|
||||||
if (region_xlo < domain->boxlo[0] || region_xhi > domain->boxhi[0] ||
|
if (region_xlo < domain->boxlo[0] || region_xhi > domain->boxhi[0] ||
|
||||||
region_ylo < domain->boxlo[1] || region_yhi > domain->boxhi[1] ||
|
region_ylo < domain->boxlo[1] || region_yhi > domain->boxhi[1] ||
|
||||||
@ -131,15 +128,14 @@ FixWidom::FixWidom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
if (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) != 0)
|
if (region->match(coord[0],coord[1],coord[2]) != 0)
|
||||||
inside++;
|
inside++;
|
||||||
}
|
}
|
||||||
|
|
||||||
double max_region_volume = (region_xhi - region_xlo) *
|
double max_region_volume = (region_xhi - region_xlo) *
|
||||||
(region_yhi - region_ylo) * (region_zhi - region_zlo);
|
(region_yhi - region_ylo) * (region_zhi - region_zlo);
|
||||||
|
|
||||||
region_volume = max_region_volume*static_cast<double> (inside)/
|
region_volume = max_region_volume * static_cast<double>(inside) / static_cast<double>(attempts);
|
||||||
static_cast<double> (attempts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// error check and further setup for exchmode = EXCHMOL
|
// error check and further setup for exchmode = EXCHMOL
|
||||||
@ -191,8 +187,6 @@ void FixWidom::options(int narg, char **arg)
|
|||||||
// defaults
|
// defaults
|
||||||
|
|
||||||
exchmode = EXCHATOM;
|
exchmode = EXCHATOM;
|
||||||
regionflag = 0;
|
|
||||||
iregion = -1;
|
|
||||||
region_volume = 0;
|
region_volume = 0;
|
||||||
max_region_attempts = 1000;
|
max_region_attempts = 1000;
|
||||||
molecule_group = 0;
|
molecule_group = 0;
|
||||||
@ -221,11 +215,10 @@ void FixWidom::options(int narg, char **arg)
|
|||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"region") == 0) {
|
} else if (strcmp(arg[iarg],"region") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix widom command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix widom command");
|
||||||
iregion = domain->find_region(arg[iarg+1]);
|
region = domain->get_region_by_id(arg[iarg+1]);
|
||||||
if (iregion == -1)
|
if (!region)
|
||||||
error->all(FLERR,"Region ID for fix widom does not exist");
|
error->all(FLERR,"Region {} for fix widom does not exist",arg[iarg+1]);
|
||||||
idregion = utils::strdup(arg[iarg+1]);
|
idregion = utils::strdup(arg[iarg+1]);
|
||||||
regionflag = 1;
|
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"charge") == 0) {
|
} else if (strcmp(arg[iarg],"charge") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix widom command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix widom command");
|
||||||
@ -247,7 +240,7 @@ void FixWidom::options(int narg, char **arg)
|
|||||||
|
|
||||||
FixWidom::~FixWidom()
|
FixWidom::~FixWidom()
|
||||||
{
|
{
|
||||||
if (regionflag) delete [] idregion;
|
delete[] idregion;
|
||||||
delete random_equal;
|
delete random_equal;
|
||||||
|
|
||||||
memory->destroy(local_gas_list);
|
memory->destroy(local_gas_list);
|
||||||
@ -271,11 +264,18 @@ int FixWidom::setmask()
|
|||||||
void FixWidom::init()
|
void FixWidom::init()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// set index and check validity of region
|
||||||
|
|
||||||
|
if (idregion) {
|
||||||
|
region = domain->get_region_by_id(idregion);
|
||||||
|
if (!region) error->all(FLERR, "Region {} for fix widom does not exist", idregion);
|
||||||
|
}
|
||||||
|
|
||||||
triclinic = domain->triclinic;
|
triclinic = domain->triclinic;
|
||||||
|
|
||||||
ave_widom_chemical_potential = 0;
|
ave_widom_chemical_potential = 0;
|
||||||
|
|
||||||
if (regionflag) volume = region_volume;
|
if (region) volume = region_volume;
|
||||||
else volume = domain->xprd * domain->yprd * domain->zprd;
|
else volume = domain->xprd * domain->yprd * domain->zprd;
|
||||||
|
|
||||||
// decide whether to switch to the full_energy option
|
// decide whether to switch to the full_energy option
|
||||||
@ -283,8 +283,8 @@ void FixWidom::init()
|
|||||||
if ((force->kspace) ||
|
if ((force->kspace) ||
|
||||||
(force->pair == nullptr) ||
|
(force->pair == nullptr) ||
|
||||||
(force->pair->single_enable == 0) ||
|
(force->pair->single_enable == 0) ||
|
||||||
(force->pair_match("hybrid",0)) ||
|
(force->pair_match("^hybrid",0)) ||
|
||||||
(force->pair_match("eam",0)) ||
|
(force->pair_match("^eam",0)) ||
|
||||||
(force->pair->tail_flag)) {
|
(force->pair->tail_flag)) {
|
||||||
full_flag = true;
|
full_flag = true;
|
||||||
if (comm->me == 0)
|
if (comm->me == 0)
|
||||||
@ -434,7 +434,7 @@ void FixWidom::pre_exchange()
|
|||||||
subhi = domain->subhi;
|
subhi = domain->subhi;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regionflag) volume = region_volume;
|
if (region) volume = region_volume;
|
||||||
else volume = domain->xprd * domain->yprd * domain->zprd;
|
else volume = domain->xprd * domain->yprd * domain->zprd;
|
||||||
|
|
||||||
if (triclinic) domain->x2lamda(atom->nlocal);
|
if (triclinic) domain->x2lamda(atom->nlocal);
|
||||||
@ -486,12 +486,12 @@ void FixWidom::attempt_atomic_insertion()
|
|||||||
|
|
||||||
// pick coordinates for insertion point
|
// pick coordinates for insertion point
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int region_attempt = 0;
|
int region_attempt = 0;
|
||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
|
while (region->match(coord[0],coord[1],coord[2]) == 0) {
|
||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
@ -562,7 +562,7 @@ void FixWidom::attempt_molecule_insertion()
|
|||||||
|
|
||||||
for (int imove = 0; imove < ninsertions; imove++) {
|
for (int imove = 0; imove < ninsertions; imove++) {
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int region_attempt = 0;
|
int region_attempt = 0;
|
||||||
com_coord[0] = region_xlo + random_equal->uniform() *
|
com_coord[0] = region_xlo + random_equal->uniform() *
|
||||||
(region_xhi-region_xlo);
|
(region_xhi-region_xlo);
|
||||||
@ -570,7 +570,7 @@ void FixWidom::attempt_molecule_insertion()
|
|||||||
(region_yhi-region_ylo);
|
(region_yhi-region_ylo);
|
||||||
com_coord[2] = region_zlo + random_equal->uniform() *
|
com_coord[2] = region_zlo + random_equal->uniform() *
|
||||||
(region_zhi-region_zlo);
|
(region_zhi-region_zlo);
|
||||||
while (domain->regions[iregion]->match(com_coord[0],com_coord[1],
|
while (region->match(com_coord[0],com_coord[1],
|
||||||
com_coord[2]) == 0) {
|
com_coord[2]) == 0) {
|
||||||
com_coord[0] = region_xlo + random_equal->uniform() *
|
com_coord[0] = region_xlo + random_equal->uniform() *
|
||||||
(region_xhi-region_xlo);
|
(region_xhi-region_xlo);
|
||||||
@ -688,12 +688,12 @@ void FixWidom::attempt_atomic_insertion_full()
|
|||||||
|
|
||||||
for (int imove = 0; imove < ninsertions; imove++) {
|
for (int imove = 0; imove < ninsertions; imove++) {
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int region_attempt = 0;
|
int region_attempt = 0;
|
||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
|
while (region->match(coord[0],coord[1],coord[2]) == 0) {
|
||||||
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
|
||||||
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
|
||||||
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
coord[2] = region_zlo + random_equal->uniform() * (region_zhi-region_zlo);
|
||||||
@ -801,7 +801,7 @@ void FixWidom::attempt_molecule_insertion_full()
|
|||||||
|
|
||||||
for (int imove = 0; imove < ninsertions; imove++) {
|
for (int imove = 0; imove < ninsertions; imove++) {
|
||||||
double com_coord[3];
|
double com_coord[3];
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
int region_attempt = 0;
|
int region_attempt = 0;
|
||||||
com_coord[0] = region_xlo + random_equal->uniform() *
|
com_coord[0] = region_xlo + random_equal->uniform() *
|
||||||
(region_xhi-region_xlo);
|
(region_xhi-region_xlo);
|
||||||
@ -809,7 +809,7 @@ void FixWidom::attempt_molecule_insertion_full()
|
|||||||
(region_yhi-region_ylo);
|
(region_yhi-region_ylo);
|
||||||
com_coord[2] = region_zlo + random_equal->uniform() *
|
com_coord[2] = region_zlo + random_equal->uniform() *
|
||||||
(region_zhi-region_zlo);
|
(region_zhi-region_zlo);
|
||||||
while (domain->regions[iregion]->match(com_coord[0],com_coord[1],
|
while (region->match(com_coord[0],com_coord[1],
|
||||||
com_coord[2]) == 0) {
|
com_coord[2]) == 0) {
|
||||||
com_coord[0] = region_xlo + random_equal->uniform() *
|
com_coord[0] = region_xlo + random_equal->uniform() *
|
||||||
(region_xhi-region_xlo);
|
(region_xhi-region_xlo);
|
||||||
@ -1081,7 +1081,7 @@ void FixWidom::update_gas_atoms_list()
|
|||||||
|
|
||||||
ngas_local = 0;
|
ngas_local = 0;
|
||||||
|
|
||||||
if (regionflag) {
|
if (region) {
|
||||||
|
|
||||||
if (exchmode == EXCHMOL) {
|
if (exchmode == EXCHMOL) {
|
||||||
|
|
||||||
@ -1114,7 +1114,7 @@ void FixWidom::update_gas_atoms_list()
|
|||||||
|
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (domain->regions[iregion]->match(comx[molecule[i]],
|
if (region->match(comx[molecule[i]],
|
||||||
comy[molecule[i]],comz[molecule[i]]) == 1) {
|
comy[molecule[i]],comz[molecule[i]]) == 1) {
|
||||||
local_gas_list[ngas_local] = i;
|
local_gas_list[ngas_local] = i;
|
||||||
ngas_local++;
|
ngas_local++;
|
||||||
@ -1127,7 +1127,7 @@ void FixWidom::update_gas_atoms_list()
|
|||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]) == 1) {
|
if (region->match(x[i][0],x[i][1],x[i][2]) == 1) {
|
||||||
local_gas_list[ngas_local] = i;
|
local_gas_list[ngas_local] = i;
|
||||||
ngas_local++;
|
ngas_local++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,8 +57,7 @@ class FixWidom : public Fix {
|
|||||||
int ngas_local; // # of gas atoms on this proc
|
int ngas_local; // # of gas atoms on this proc
|
||||||
int exchmode; // exchange ATOM or MOLECULE
|
int exchmode; // exchange ATOM or MOLECULE
|
||||||
int movemode; // move ATOM or MOLECULE
|
int movemode; // move ATOM or MOLECULE
|
||||||
int regionflag; // 0 = anywhere in box, 1 = specific region
|
class Region *region; // widom region
|
||||||
int iregion; // widom region
|
|
||||||
char *idregion; // widom region id
|
char *idregion; // widom region id
|
||||||
bool charge_flag; // true if user specified atomic charge
|
bool charge_flag; // true if user specified atomic charge
|
||||||
bool full_flag; // true if doing full system energy calculations
|
bool full_flag; // true if doing full system energy calculations
|
||||||
|
|||||||
@ -64,8 +64,7 @@ class PairMesoCNT : public Pair {
|
|||||||
void sort(int *, int);
|
void sort(int *, int);
|
||||||
void read_file(const char *);
|
void read_file(const char *);
|
||||||
void read_data(PotentialFileReader &, double *, double &, double &, int);
|
void read_data(PotentialFileReader &, double *, double &, double &, int);
|
||||||
void read_data(PotentialFileReader &, double **, double &, double &, double &, double &,
|
void read_data(PotentialFileReader &, double **, double &, double &, double &, double &, int);
|
||||||
int);
|
|
||||||
|
|
||||||
void spline_coeff(double *, double **, double, int);
|
void spline_coeff(double *, double **, double, int);
|
||||||
void spline_coeff(double **, double ****, double, double, int);
|
void spline_coeff(double **, double ****, double, double, int);
|
||||||
|
|||||||
@ -62,7 +62,9 @@ MLIAPModelPython::MLIAPModelPython(LAMMPS *lmp, char *coefffilename) :
|
|||||||
|
|
||||||
// if LAMMPS_POTENTIALS environment variable is set, add it to PYTHONPATH as well
|
// if LAMMPS_POTENTIALS environment variable is set, add it to PYTHONPATH as well
|
||||||
const char *potentials_path = getenv("LAMMPS_POTENTIALS");
|
const char *potentials_path = getenv("LAMMPS_POTENTIALS");
|
||||||
if (potentials_path != nullptr) { PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path)); }
|
if (potentials_path != nullptr) {
|
||||||
|
PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path));
|
||||||
|
}
|
||||||
PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
|
|
||||||
if (coefffilename) read_coeffs(coefffilename);
|
if (coefffilename) read_coeffs(coefffilename);
|
||||||
|
|||||||
@ -46,7 +46,8 @@ namespace RANN {
|
|||||||
void allocate() override;
|
void allocate() override;
|
||||||
void compute_fingerprint(double *, double *, double *, double *, double *, double *, double *,
|
void compute_fingerprint(double *, double *, double *, double *, double *, double *, double *,
|
||||||
double *, double *, double *, double *, double *, double *, double *,
|
double *, double *, double *, double *, double *, double *, double *,
|
||||||
bool *, int, int, double *, double *, double *, int *, int, int *) override;
|
bool *, int, int, double *, double *, double *, int *, int,
|
||||||
|
int *) override;
|
||||||
void do3bodyfeatureset_doubleneighborloop(double *, double *, double *, double *, double *,
|
void do3bodyfeatureset_doubleneighborloop(double *, double *, double *, double *, double *,
|
||||||
double *, double *, double *, double *, double *,
|
double *, double *, double *, double *, double *,
|
||||||
double *, double *, double *, double *, bool *, int,
|
double *, double *, double *, double *, bool *, int,
|
||||||
|
|||||||
@ -43,8 +43,8 @@ namespace RANN {
|
|||||||
void write_values(FILE *) override;
|
void write_values(FILE *) override;
|
||||||
void init(int *, int) override;
|
void init(int *, int) override;
|
||||||
void allocate() override;
|
void allocate() override;
|
||||||
void compute_fingerprint(double *, double *, double *, double *, double *, double *,
|
void compute_fingerprint(double *, double *, double *, double *, double *, double *, double *,
|
||||||
double *, int, int, double *, double *, double *, int *, int,
|
int, int, double *, double *, double *, int *, int,
|
||||||
int *) override; //spin
|
int *) override; //spin
|
||||||
void do3bodyfeatureset_doubleneighborloop(double *, double *, double *, double *, double *,
|
void do3bodyfeatureset_doubleneighborloop(double *, double *, double *, double *, double *,
|
||||||
double *, double *, int, int, double *, double *,
|
double *, double *, int, int, double *, double *,
|
||||||
|
|||||||
@ -43,10 +43,10 @@ namespace RANN {
|
|||||||
void write_values(FILE *) override;
|
void write_values(FILE *) override;
|
||||||
void init(int *, int) override;
|
void init(int *, int) override;
|
||||||
void allocate() override;
|
void allocate() override;
|
||||||
void compute_fingerprint(double *, double *, double *, double *, double *, double *,
|
void compute_fingerprint(double *, double *, double *, double *, double *, double *, double *,
|
||||||
double *, double *, double *, double *, double *, double *,
|
double *, double *, double *, double *, double *, double *, double *,
|
||||||
double *, double *, bool *, int, int, double *, double *,
|
bool *, int, int, double *, double *, double *, int *, int,
|
||||||
double *, int *, int, int *) override; //spin,screen
|
int *) override; //spin,screen
|
||||||
int get_length() override;
|
int get_length() override;
|
||||||
|
|
||||||
double *radialtable;
|
double *radialtable;
|
||||||
|
|||||||
@ -692,7 +692,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename)
|
|||||||
|
|
||||||
if (keywd == "rinner" || keywd == "drinner") {
|
if (keywd == "rinner" || keywd == "drinner") {
|
||||||
|
|
||||||
if (words.size() != nelements+1)
|
if ((int)words.size() != nelements+1)
|
||||||
error->all(FLERR,"Incorrect SNAP parameter file");
|
error->all(FLERR,"Incorrect SNAP parameter file");
|
||||||
|
|
||||||
if (comm->me == 0)
|
if (comm->me == 0)
|
||||||
|
|||||||
@ -124,8 +124,7 @@ class SNA : protected Pointers {
|
|||||||
void compute_uarray(double, double, double, double, double, int);
|
void compute_uarray(double, double, double, double, double, int);
|
||||||
double deltacg(int, int, int);
|
double deltacg(int, int, int);
|
||||||
void compute_ncoeff();
|
void compute_ncoeff();
|
||||||
void compute_duarray(double, double, double, double, double, double,
|
void compute_duarray(double, double, double, double, double, double, double, double, int);
|
||||||
double, double, int);
|
|
||||||
|
|
||||||
// Sets the style for the switching function
|
// Sets the style for the switching function
|
||||||
// 0 = none
|
// 0 = none
|
||||||
|
|||||||
@ -240,7 +240,7 @@ double AngleCosine::single(int type, int i1, int i2, int i3)
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void AngleCosine::born_matrix(int type, int i1, int i2, int i3, double &du, double &du2)
|
void AngleCosine::born_matrix(int type, int /*i1*/, int /*i2*/, int /*i3*/, double &du, double &du2)
|
||||||
{
|
{
|
||||||
du2 = 0;
|
du2 = 0;
|
||||||
du = k[type];
|
du = k[type];
|
||||||
|
|||||||
@ -288,7 +288,6 @@ void AngleCosineSquared::born_matrix(int type, int i1, int i2, int i3, double& d
|
|||||||
if (c < -1.0) c = -1.0;
|
if (c < -1.0) c = -1.0;
|
||||||
|
|
||||||
double dcostheta = c - cos(theta0[type]);
|
double dcostheta = c - cos(theta0[type]);
|
||||||
double tk = k[type] * dcostheta;
|
|
||||||
du2 = 2*k[type];
|
du2 = 2*k[type];
|
||||||
du = du2*dcostheta;
|
du = du2*dcostheta;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,8 +35,8 @@ class ReaderMolfile : public Reader {
|
|||||||
|
|
||||||
int read_time(bigint &) override;
|
int read_time(bigint &) override;
|
||||||
void skip() override;
|
void skip() override;
|
||||||
bigint read_header(double[3][3], int &, int &, int, int, int *, char **, int, int, int &,
|
bigint read_header(double[3][3], int &, int &, int, int, int *, char **, int, int, int &, int &,
|
||||||
int &, int &, int &) override;
|
int &, int &) override;
|
||||||
void read_atoms(int, int, double **) override;
|
void read_atoms(int, int, double **) override;
|
||||||
|
|
||||||
void open_file(const std::string &) override;
|
void open_file(const std::string &) override;
|
||||||
|
|||||||
@ -38,8 +38,7 @@ using namespace LAMMPS_NS;
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
DumpAtomMPIIO::DumpAtomMPIIO(LAMMPS *lmp, int narg, char **arg)
|
DumpAtomMPIIO::DumpAtomMPIIO(LAMMPS *lmp, int narg, char **arg) : DumpAtom(lmp, narg, arg)
|
||||||
: DumpAtom(lmp, narg, arg)
|
|
||||||
{
|
{
|
||||||
if (me == 0)
|
if (me == 0)
|
||||||
error->warning(FLERR, "MPI-IO output is unmaintained and unreliable. Use with caution.");
|
error->warning(FLERR, "MPI-IO output is unmaintained and unreliable. Use with caution.");
|
||||||
@ -86,8 +85,8 @@ void DumpAtomMPIIO::openfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (append_flag) { // append open
|
if (append_flag) { // append open
|
||||||
int err = MPI_File_open(world, filecurrent, MPI_MODE_CREATE | MPI_MODE_APPEND |
|
int err = MPI_File_open(world, filecurrent, MPI_MODE_CREATE | MPI_MODE_APPEND | MPI_MODE_WRONLY,
|
||||||
MPI_MODE_WRONLY, MPI_INFO_NULL, &mpifh);
|
MPI_INFO_NULL, &mpifh);
|
||||||
if (err != MPI_SUCCESS)
|
if (err != MPI_SUCCESS)
|
||||||
error->one(FLERR, "Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
error->one(FLERR, "Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
||||||
|
|
||||||
@ -100,8 +99,8 @@ void DumpAtomMPIIO::openfile()
|
|||||||
|
|
||||||
} else { // replace open
|
} else { // replace open
|
||||||
|
|
||||||
int err = MPI_File_open(world, filecurrent, MPI_MODE_CREATE | MPI_MODE_WRONLY,
|
int err =
|
||||||
MPI_INFO_NULL, &mpifh);
|
MPI_File_open(world, filecurrent, MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &mpifh);
|
||||||
if (err != MPI_SUCCESS)
|
if (err != MPI_SUCCESS)
|
||||||
error->one(FLERR, "Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
error->one(FLERR, "Cannot open dump file {}: {}", filecurrent, utils::getsyserror());
|
||||||
|
|
||||||
@ -214,8 +213,10 @@ void DumpAtomMPIIO::init_style()
|
|||||||
if (format_line_user) {
|
if (format_line_user) {
|
||||||
format = utils::strdup(std::string(format_line_user) + "\n");
|
format = utils::strdup(std::string(format_line_user) + "\n");
|
||||||
} else {
|
} else {
|
||||||
if (image_flag == 0) format = utils::strdup(TAGINT_FORMAT " %d %g %g %g\n");
|
if (image_flag == 0)
|
||||||
else format = utils::strdup(TAGINT_FORMAT " %d %g %g %g %d %d %d\n");
|
format = utils::strdup(TAGINT_FORMAT " %d %g %g %g\n");
|
||||||
|
else
|
||||||
|
format = utils::strdup(TAGINT_FORMAT " %d %g %g %g %d %d %d\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup boundary string
|
// setup boundary string
|
||||||
@ -239,8 +240,10 @@ void DumpAtomMPIIO::init_style()
|
|||||||
columns.clear();
|
columns.clear();
|
||||||
for (auto item : utils::split_words(default_columns)) {
|
for (auto item : utils::split_words(default_columns)) {
|
||||||
if (columns.size()) columns += " ";
|
if (columns.size()) columns += " ";
|
||||||
if (keyword_user[icol].size()) columns += keyword_user[icol];
|
if (keyword_user[icol].size())
|
||||||
else columns += item;
|
columns += keyword_user[icol];
|
||||||
|
else
|
||||||
|
columns += item;
|
||||||
++icol;
|
++icol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,8 +41,7 @@ using namespace LAMMPS_NS;
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
DumpCustomMPIIO::DumpCustomMPIIO(LAMMPS *lmp, int narg, char **arg)
|
DumpCustomMPIIO::DumpCustomMPIIO(LAMMPS *lmp, int narg, char **arg) : DumpCustom(lmp, narg, arg)
|
||||||
: DumpCustom(lmp, narg, arg)
|
|
||||||
{
|
{
|
||||||
if (me == 0)
|
if (me == 0)
|
||||||
error->warning(FLERR, "MPI-IO output is unmaintained and unreliable. Use with caution.");
|
error->warning(FLERR, "MPI-IO output is unmaintained and unreliable. Use with caution.");
|
||||||
@ -212,8 +211,10 @@ void DumpCustomMPIIO::init_style()
|
|||||||
int icol = 0;
|
int icol = 0;
|
||||||
for (auto item : utils::split_words(columns_default)) {
|
for (auto item : utils::split_words(columns_default)) {
|
||||||
if (combined.size()) combined += " ";
|
if (combined.size()) combined += " ";
|
||||||
if (keyword_user[icol].size()) combined += keyword_user[icol];
|
if (keyword_user[icol].size())
|
||||||
else combined += item;
|
combined += keyword_user[icol];
|
||||||
|
else
|
||||||
|
combined += item;
|
||||||
++icol;
|
++icol;
|
||||||
}
|
}
|
||||||
columns = utils::strdup(combined);
|
columns = utils::strdup(combined);
|
||||||
@ -221,8 +222,10 @@ void DumpCustomMPIIO::init_style()
|
|||||||
// format = copy of default or user-specified line format
|
// format = copy of default or user-specified line format
|
||||||
|
|
||||||
delete[] format;
|
delete[] format;
|
||||||
if (format_line_user) format = utils::strdup(format_line_user);
|
if (format_line_user)
|
||||||
else format = utils::strdup(format_default);
|
format = utils::strdup(format_line_user);
|
||||||
|
else
|
||||||
|
format = utils::strdup(format_default);
|
||||||
|
|
||||||
// tokenize the format string and add space at end of each format element
|
// tokenize the format string and add space at end of each format element
|
||||||
// if user-specified int/float format exists, use it instead
|
// if user-specified int/float format exists, use it instead
|
||||||
@ -230,8 +233,7 @@ void DumpCustomMPIIO::init_style()
|
|||||||
// lo priority = line, medium priority = int/float, hi priority = column
|
// lo priority = line, medium priority = int/float, hi priority = column
|
||||||
|
|
||||||
auto words = utils::split_words(format);
|
auto words = utils::split_words(format);
|
||||||
if ((int) words.size() < nfield)
|
if ((int) words.size() < nfield) error->all(FLERR, "Dump_modify format line is too short");
|
||||||
error->all(FLERR,"Dump_modify format line is too short");
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto &word : words) {
|
for (const auto &word : words) {
|
||||||
@ -245,7 +247,8 @@ void DumpCustomMPIIO::init_style()
|
|||||||
vformat[i] = utils::strdup(std::string(format_float_user) + " ");
|
vformat[i] = utils::strdup(std::string(format_float_user) + " ");
|
||||||
else if (vtype[i] == Dump::BIGINT && format_bigint_user)
|
else if (vtype[i] == Dump::BIGINT && format_bigint_user)
|
||||||
vformat[i] = utils::strdup(std::string(format_bigint_user) + " ");
|
vformat[i] = utils::strdup(std::string(format_bigint_user) + " ");
|
||||||
else vformat[i] = utils::strdup(word + " ");
|
else
|
||||||
|
vformat[i] = utils::strdup(word + " ");
|
||||||
|
|
||||||
// remove trailing blank on last column's format
|
// remove trailing blank on last column's format
|
||||||
if (i == nfield - 1) vformat[i][strlen(vformat[i]) - 1] = '\0';
|
if (i == nfield - 1) vformat[i][strlen(vformat[i]) - 1] = '\0';
|
||||||
@ -278,29 +281,28 @@ void DumpCustomMPIIO::init_style()
|
|||||||
|
|
||||||
for (i = 0; i < ncompute; i++) {
|
for (i = 0; i < ncompute; i++) {
|
||||||
compute[i] = modify->get_compute_by_id(id_compute[i]);
|
compute[i] = modify->get_compute_by_id(id_compute[i]);
|
||||||
if (!compute[i]) error->all(FLERR,"Could not find dump custom compute ID {}",id_compute[i]);
|
if (!compute[i])
|
||||||
|
error->all(FLERR, "Could not find dump custom/mpiio compute ID {}", id_compute[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nfix; i++) {
|
for (i = 0; i < nfix; i++) {
|
||||||
fix[i] = modify->get_fix_by_id(id_fix[i]);
|
fix[i] = modify->get_fix_by_id(id_fix[i]);
|
||||||
if (!fix[i]) error->all(FLERR,"Could not find dump custom fix ID {}", id_fix[i]);
|
if (!fix[i]) error->all(FLERR, "Could not find dump custom/mpiio fix ID {}", id_fix[i]);
|
||||||
if (nevery % fix[i]->peratom_freq)
|
if (nevery % fix[i]->peratom_freq)
|
||||||
error->all(FLERR,"Dump custom and fix not computed at compatible times");
|
error->all(FLERR, "dump custom/mpiio and fix not computed at compatible times");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nvariable; i++) {
|
for (i = 0; i < nvariable; i++) {
|
||||||
int ivariable = input->variable->find(id_variable[i]);
|
int ivariable = input->variable->find(id_variable[i]);
|
||||||
if (ivariable < 0)
|
if (ivariable < 0)
|
||||||
error->all(FLERR,"Could not find dump custom variable name {}", id_variable[i]);
|
error->all(FLERR, "Could not find dump custom/mpiio variable name {}", id_variable[i]);
|
||||||
variable[i] = ivariable;
|
variable[i] = ivariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
|
|
||||||
if (iregion >= 0) {
|
if (idregion && !domain->get_region_by_id(idregion))
|
||||||
iregion = domain->find_region(idregion);
|
error->all(FLERR, "Region {} for dump custom/mpiio does not exist", idregion);
|
||||||
if (iregion == -1) error->all(FLERR, "Region ID for dump custom does not exist");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -37,8 +37,8 @@ class PPPMDispOMP : public PPPMDisp, public ThrOMP {
|
|||||||
virtual void compute_gf();
|
virtual void compute_gf();
|
||||||
virtual void compute_gf_6();
|
virtual void compute_gf_6();
|
||||||
|
|
||||||
void particle_map(double, double, double, double, int **, int, int, int, int, int, int,
|
void particle_map(double, double, double, double, int **, int, int, int, int, int, int, int,
|
||||||
int, int) override;
|
int) override;
|
||||||
|
|
||||||
void fieldforce_c_ik() override;
|
void fieldforce_c_ik() override;
|
||||||
void fieldforce_c_ad() override;
|
void fieldforce_c_ad() override;
|
||||||
|
|||||||
@ -38,10 +38,10 @@ class PPPMDispTIP4POMP : public PPPMDispTIP4P, public ThrOMP {
|
|||||||
|
|
||||||
void compute(int, int) override;
|
void compute(int, int) override;
|
||||||
|
|
||||||
void particle_map(double, double, double, double, int **, int, int, int, int, int, int,
|
void particle_map(double, double, double, double, int **, int, int, int, int, int, int, int,
|
||||||
int, int) override;
|
int) override;
|
||||||
void particle_map_c(double, double, double, double, int **, int, int, int, int, int, int,
|
void particle_map_c(double, double, double, double, int **, int, int, int, int, int, int, int,
|
||||||
int, int) override;
|
int) override;
|
||||||
void make_rho_c() override; // XXX: not (yet) multi-threaded
|
void make_rho_c() override; // XXX: not (yet) multi-threaded
|
||||||
void make_rho_g() override;
|
void make_rho_g() override;
|
||||||
void make_rho_a() override;
|
void make_rho_a() override;
|
||||||
|
|||||||
@ -70,7 +70,8 @@ class FixOrientBCC : public Fix {
|
|||||||
|
|
||||||
bool use_xismooth;
|
bool use_xismooth;
|
||||||
static constexpr int half_bcc_nn = 4;
|
static constexpr int half_bcc_nn = 4;
|
||||||
double Rxi[half_bcc_nn][3] = {}, Rchi[half_bcc_nn][3] = {}, half_xi_chi_vec[2][half_bcc_nn][3] = {};
|
double Rxi[half_bcc_nn][3] = {}, Rchi[half_bcc_nn][3] = {},
|
||||||
|
half_xi_chi_vec[2][half_bcc_nn][3] = {};
|
||||||
double xiid, xi0, xi1, xicutoffsq, cutsq, added_energy;
|
double xiid, xi0, xi1, xicutoffsq, cutsq, added_energy;
|
||||||
|
|
||||||
int nmax; // expose 2 per-atom quantities
|
int nmax; // expose 2 per-atom quantities
|
||||||
|
|||||||
@ -70,7 +70,8 @@ class FixOrientFCC : public Fix {
|
|||||||
|
|
||||||
bool use_xismooth;
|
bool use_xismooth;
|
||||||
static constexpr int half_fcc_nn = 6;
|
static constexpr int half_fcc_nn = 6;
|
||||||
double Rxi[half_fcc_nn][3] = {}, Rchi[half_fcc_nn][3] = {}, half_xi_chi_vec[2][half_fcc_nn][3] = {};
|
double Rxi[half_fcc_nn][3] = {}, Rchi[half_fcc_nn][3] = {},
|
||||||
|
half_xi_chi_vec[2][half_fcc_nn][3] = {};
|
||||||
double xiid, xi0, xi1, xicutoffsq, cutsq, added_energy;
|
double xiid, xi0, xi1, xicutoffsq, cutsq, added_energy;
|
||||||
|
|
||||||
int nmax; // expose 2 per-atom quantities
|
int nmax; // expose 2 per-atom quantities
|
||||||
|
|||||||
@ -26,7 +26,6 @@ class ThirdOrder : public Command {
|
|||||||
int eflag, vflag; // flags for energy/virial computation
|
int eflag, vflag; // flags for energy/virial computation
|
||||||
int external_force_clear; // clear forces locally or externally
|
int external_force_clear; // clear forces locally or externally
|
||||||
|
|
||||||
|
|
||||||
int triclinic; // 0 if domain is orthog, 1 if triclinic
|
int triclinic; // 0 if domain is orthog, 1 if triclinic
|
||||||
int pairflag;
|
int pairflag;
|
||||||
|
|
||||||
@ -39,7 +38,6 @@ class ThirdOrder : public Command {
|
|||||||
virtual void force_clear();
|
virtual void force_clear();
|
||||||
virtual void openfile(const char *filename);
|
virtual void openfile(const char *filename);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void options(int, char **);
|
void options(int, char **);
|
||||||
void create_groupmap();
|
void create_groupmap();
|
||||||
|
|||||||
@ -388,8 +388,7 @@ void plugin_unload(const char *style, const char *name, LAMMPS *lmp)
|
|||||||
auto found = region_map->find(name);
|
auto found = region_map->find(name);
|
||||||
if (found != region_map->end()) region_map->erase(name);
|
if (found != region_map->end()) region_map->erase(name);
|
||||||
|
|
||||||
for (auto iregion : lmp->domain->get_region_by_style(name))
|
for (auto iregion : lmp->domain->get_region_by_style(name)) lmp->domain->delete_region(iregion);
|
||||||
lmp->domain->delete_region(iregion->id);
|
|
||||||
|
|
||||||
} else if (pstyle == "command") {
|
} else if (pstyle == "command") {
|
||||||
|
|
||||||
|
|||||||
@ -357,8 +357,8 @@ void FixPOEMS::init()
|
|||||||
if (utils::strmatch(ifix->style, "^poems")) pflag = true;
|
if (utils::strmatch(ifix->style, "^poems")) pflag = true;
|
||||||
if (pflag && (ifix->setmask() & POST_FORCE) && !ifix->rigid_flag)
|
if (pflag && (ifix->setmask() & POST_FORCE) && !ifix->rigid_flag)
|
||||||
if (comm->me == 0)
|
if (comm->me == 0)
|
||||||
error->warning(FLERR,"Fix {} with ID {} alters forces after fix poems",
|
error->warning(FLERR, "Fix {} with ID {} alters forces after fix poems", ifix->style,
|
||||||
ifix->style, ifix->id);
|
ifix->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1096,11 +1096,8 @@ void FixQEqReaxFF::get_chi_field()
|
|||||||
|
|
||||||
// update electric field region if necessary
|
// update electric field region if necessary
|
||||||
|
|
||||||
Region *region = nullptr;
|
Region *region = efield->region;
|
||||||
if (efield->iregion >= 0) {
|
if (region) region->prematch();
|
||||||
region = domain->regions[efield->iregion];
|
|
||||||
region->prematch();
|
|
||||||
}
|
|
||||||
|
|
||||||
// efield energy is in real units of kcal/mol/angstrom, need to convert to eV
|
// efield energy is in real units of kcal/mol/angstrom, need to convert to eV
|
||||||
|
|
||||||
|
|||||||
@ -614,8 +614,7 @@ void FixPIMD::comm_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (buf_beads) {
|
if (buf_beads) {
|
||||||
for (int i = 0; i < np; i++)
|
for (int i = 0; i < np; i++) delete[] buf_beads[i];
|
||||||
delete[] buf_beads[i];
|
|
||||||
delete[] buf_beads;
|
delete[] buf_beads;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,8 +677,8 @@ void FixPIMD::comm_exec(double **ptr)
|
|||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
auto mesg = fmt::format("Atom {} is missing at world [{}] rank [{}] "
|
auto mesg = fmt::format("Atom {} is missing at world [{}] rank [{}] "
|
||||||
"required by rank [{}] ({}, {}, {}).\n",
|
"required by rank [{}] ({}, {}, {}).\n",
|
||||||
tag_send[i], universe->iworld, comm->me,
|
tag_send[i], universe->iworld, comm->me, plan_recv[iplan],
|
||||||
plan_recv[iplan], atom->tag[0], atom->tag[1], atom->tag[2]);
|
atom->tag[0], atom->tag[1], atom->tag[2]);
|
||||||
error->universe_one(FLERR, mesg);
|
error->universe_one(FLERR, mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -155,12 +155,11 @@ void Hyper::command(int narg, char **arg)
|
|||||||
|
|
||||||
// cannot use hyper with time-dependent fixes or regions
|
// cannot use hyper with time-dependent fixes or regions
|
||||||
|
|
||||||
for (int i = 0; i < modify->nfix; i++)
|
for (auto ifix : modify->get_fix_list())
|
||||||
if (modify->fix[i]->time_depend)
|
if (ifix->time_depend) error->all(FLERR,"Cannot use hyper with a time-dependent fix defined");
|
||||||
error->all(FLERR,"Cannot use hyper with a time-dependent fix defined");
|
|
||||||
|
|
||||||
for (int i = 0; i < domain->nregion; i++)
|
for (auto reg : domain->get_region_list())
|
||||||
if (domain->regions[i]->dynamic_check())
|
if (reg->dynamic_check())
|
||||||
error->all(FLERR,"Cannot use hyper with a time-dependent region defined");
|
error->all(FLERR,"Cannot use hyper with a time-dependent region defined");
|
||||||
|
|
||||||
// perform hyperdynamics simulation
|
// perform hyperdynamics simulation
|
||||||
|
|||||||
@ -229,12 +229,11 @@ void PRD::command(int narg, char **arg)
|
|||||||
|
|
||||||
// cannot use PRD with time-dependent fixes or regions
|
// cannot use PRD with time-dependent fixes or regions
|
||||||
|
|
||||||
for (int i = 0; i < modify->nfix; i++)
|
for (auto ifix : modify->get_fix_list())
|
||||||
if (modify->fix[i]->time_depend)
|
if (ifix->time_depend) error->all(FLERR,"Cannot use PRD with a time-dependent fix defined");
|
||||||
error->all(FLERR,"Cannot use PRD with a time-dependent fix defined");
|
|
||||||
|
|
||||||
for (int i = 0; i < domain->nregion; i++)
|
for (auto reg : domain->get_region_list())
|
||||||
if (domain->regions[i]->dynamic_check())
|
if (reg->dynamic_check())
|
||||||
error->all(FLERR,"Cannot use PRD with a time-dependent region defined");
|
error->all(FLERR,"Cannot use PRD with a time-dependent region defined");
|
||||||
|
|
||||||
// perform PRD simulation
|
// perform PRD simulation
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -47,8 +46,8 @@ enum{CONSTANT,EQUAL,ATOM};
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixEHEX::FixEHEX(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
FixEHEX::FixEHEX(LAMMPS *lmp, int narg, char **arg) :
|
||||||
idregion(nullptr), x(nullptr), f(nullptr), v(nullptr),
|
Fix(lmp, narg, arg), region(nullptr), idregion(nullptr), x(nullptr), f(nullptr), v(nullptr),
|
||||||
mass(nullptr), rmass(nullptr), type(nullptr), scalingmask(nullptr)
|
mass(nullptr), rmass(nullptr), type(nullptr), scalingmask(nullptr)
|
||||||
{
|
{
|
||||||
MPI_Comm_rank(world, &me);
|
MPI_Comm_rank(world, &me);
|
||||||
@ -72,8 +71,6 @@ FixEHEX::FixEHEX(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
|||||||
|
|
||||||
// optional args
|
// optional args
|
||||||
|
|
||||||
iregion = -1;
|
|
||||||
|
|
||||||
// NOTE: constraints are deactivated by default
|
// NOTE: constraints are deactivated by default
|
||||||
|
|
||||||
constraints = 0;
|
constraints = 0;
|
||||||
@ -90,10 +87,10 @@ FixEHEX::FixEHEX(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
|||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
|
|
||||||
if (strcmp(arg[iarg], "region") == 0) {
|
if (strcmp(arg[iarg], "region") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ehex command: wrong number of parameters ");
|
if (iarg + 2 > narg)
|
||||||
iregion = domain->find_region(arg[iarg+1]);
|
error->all(FLERR, "Illegal fix ehex command: wrong number of parameters ");
|
||||||
if (iregion == -1)
|
region = domain->get_region_by_id(arg[iarg + 1]);
|
||||||
error->all(FLERR,"Region ID for fix ehex does not exist");
|
if (!region) error->all(FLERR, "Region {} for fix ehex does not exist", arg[iarg + 1]);
|
||||||
idregion = utils::strdup(arg[iarg + 1]);
|
idregion = utils::strdup(arg[iarg + 1]);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
}
|
}
|
||||||
@ -117,8 +114,7 @@ FixEHEX::FixEHEX(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
|||||||
else if (strcmp(arg[iarg], "hex") == 0) {
|
else if (strcmp(arg[iarg], "hex") == 0) {
|
||||||
hex = 1;
|
hex = 1;
|
||||||
iarg += 1;
|
iarg += 1;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
error->all(FLERR, "Illegal fix ehex keyword ");
|
error->all(FLERR, "Illegal fix ehex keyword ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,17 +127,15 @@ FixEHEX::FixEHEX(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
|||||||
scalingmask = nullptr;
|
scalingmask = nullptr;
|
||||||
FixEHEX::grow_arrays(atom->nmax);
|
FixEHEX::grow_arrays(atom->nmax);
|
||||||
atom->add_callback(Atom::GROW);
|
atom->add_callback(Atom::GROW);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixEHEX::grow_arrays(int nmax) {
|
void FixEHEX::grow_arrays(int nmax)
|
||||||
|
{
|
||||||
memory->grow(scalingmask, nmax, "ehex:scalingmask");
|
memory->grow(scalingmask, nmax, "ehex:scalingmask");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixEHEX::~FixEHEX()
|
FixEHEX::~FixEHEX()
|
||||||
@ -149,7 +143,6 @@ FixEHEX::~FixEHEX()
|
|||||||
atom->delete_callback(id, Atom::GROW);
|
atom->delete_callback(id, Atom::GROW);
|
||||||
delete[] idregion;
|
delete[] idregion;
|
||||||
memory->destroy(scalingmask);
|
memory->destroy(scalingmask);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -167,16 +160,14 @@ void FixEHEX::init()
|
|||||||
{
|
{
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
|
|
||||||
if (iregion >= 0) {
|
if (idregion) {
|
||||||
iregion = domain->find_region(idregion);
|
region = domain->get_region_by_id(idregion);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for fix ehex does not exist", idregion);
|
||||||
error->all(FLERR,"Region ID for fix ehex does not exist");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cannot have 0 atoms in group
|
// cannot have 0 atoms in group
|
||||||
|
|
||||||
if (group->count(igroup) == 0)
|
if (group->count(igroup) == 0) error->all(FLERR, "Fix ehex group has no atoms");
|
||||||
error->all(FLERR,"Fix ehex group has no atoms");
|
|
||||||
|
|
||||||
fshake = nullptr;
|
fshake = nullptr;
|
||||||
if (constraints) {
|
if (constraints) {
|
||||||
@ -197,18 +188,17 @@ void FixEHEX::init()
|
|||||||
error->all(FLERR, "Multiple instances of fix shake/rattle detected (not supported yet)");
|
error->all(FLERR, "Multiple instances of fix shake/rattle detected (not supported yet)");
|
||||||
else if (cnt_shake == 1) {
|
else if (cnt_shake == 1) {
|
||||||
fshake = (dynamic_cast<FixShake *>(modify->fix[id_shake]));
|
fshake = (dynamic_cast<FixShake *>(modify->fix[id_shake]));
|
||||||
}
|
} else if (cnt_shake == 0)
|
||||||
else if (cnt_shake == 0)
|
error->all(
|
||||||
error->all(FLERR, "Fix ehex was configured with keyword constrain, but shake/rattle was not defined");
|
FLERR,
|
||||||
|
"Fix ehex was configured with keyword constrain, but shake/rattle was not defined");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixEHEX::end_of_step()
|
||||||
void FixEHEX::end_of_step() {
|
{
|
||||||
// store local pointers
|
// store local pointers
|
||||||
|
|
||||||
x = atom->x;
|
x = atom->x;
|
||||||
@ -229,18 +219,16 @@ void FixEHEX::end_of_step() {
|
|||||||
|
|
||||||
// if required use shake/rattle to correct coordinates and velocities
|
// if required use shake/rattle to correct coordinates and velocities
|
||||||
|
|
||||||
if (constraints && fshake)
|
if (constraints && fshake) fshake->shake_end_of_step(0);
|
||||||
fshake->shake_end_of_step(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
Iterate over all atoms, rescale the velocities and apply coordinate
|
Iterate over all atoms, rescale the velocities and apply coordinate
|
||||||
corrections.
|
corrections.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixEHEX::rescale() {
|
void FixEHEX::rescale()
|
||||||
|
{
|
||||||
double Kr, Ke, escale;
|
double Kr, Ke, escale;
|
||||||
double vsub[3], vcm[3], sfr[3];
|
double vsub[3], vcm[3], sfr[3];
|
||||||
double mi;
|
double mi;
|
||||||
@ -289,7 +277,8 @@ void FixEHEX::rescale() {
|
|||||||
// epsr_ik implements Eq. (20) in the paper
|
// epsr_ik implements Eq. (20) in the paper
|
||||||
|
|
||||||
eta_ik = mi * F / (2. * Kr) * (v[i][k] - vcm[k]);
|
eta_ik = mi * F / (2. * Kr) * (v[i][k] - vcm[k]);
|
||||||
epsr_ik = eta_ik / (mi*Kr) * (F/48. + sfvr/6.*force->ftm2v) - F/(12.*Kr) * (f[i][k]/mi - sfr[k]/mr)*force->ftm2v;
|
epsr_ik = eta_ik / (mi * Kr) * (F / 48. + sfvr / 6. * force->ftm2v) -
|
||||||
|
F / (12. * Kr) * (f[i][k] / mi - sfr[k] / mr) * force->ftm2v;
|
||||||
|
|
||||||
x[i][k] -= dt * dt * dt * epsr_ik;
|
x[i][k] -= dt * dt * dt * epsr_ik;
|
||||||
}
|
}
|
||||||
@ -302,7 +291,6 @@ void FixEHEX::rescale() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
double FixEHEX::compute_scalar()
|
double FixEHEX::compute_scalar()
|
||||||
@ -321,13 +309,13 @@ double FixEHEX::memory_usage()
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
Update the array scalingmask depending on which individual atoms
|
Update the array scalingmask depending on which individual atoms
|
||||||
will be rescaled or not.
|
will be rescaled or not.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixEHEX::update_scalingmask() {
|
void FixEHEX::update_scalingmask()
|
||||||
|
{
|
||||||
int m;
|
int m;
|
||||||
int lid;
|
int lid;
|
||||||
bool stat;
|
bool stat;
|
||||||
@ -335,11 +323,7 @@ void FixEHEX::update_scalingmask() {
|
|||||||
|
|
||||||
// prematch region
|
// prematch region
|
||||||
|
|
||||||
Region *region = nullptr;
|
if (region) region->prematch();
|
||||||
if (iregion >= 0) {
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
|
||||||
}
|
|
||||||
|
|
||||||
// only rescale molecules whose center of mass if fully contained in the region
|
// only rescale molecules whose center of mass if fully contained in the region
|
||||||
|
|
||||||
@ -356,11 +340,16 @@ void FixEHEX::update_scalingmask() {
|
|||||||
// check if the centre of mass of the cluster is inside the region
|
// check if the centre of mass of the cluster is inside the region
|
||||||
// if region == nullptr, just check the group information of all sites
|
// if region == nullptr, just check the group information of all sites
|
||||||
|
|
||||||
if (fshake->shake_flag[m] == 1) nsites = 3;
|
if (fshake->shake_flag[m] == 1)
|
||||||
else if (fshake->shake_flag[m] == 2) nsites = 2;
|
nsites = 3;
|
||||||
else if (fshake->shake_flag[m] == 3) nsites = 3;
|
else if (fshake->shake_flag[m] == 2)
|
||||||
else if (fshake->shake_flag[m] == 4) nsites = 4;
|
nsites = 2;
|
||||||
else nsites = 0;
|
else if (fshake->shake_flag[m] == 3)
|
||||||
|
nsites = 3;
|
||||||
|
else if (fshake->shake_flag[m] == 4)
|
||||||
|
nsites = 4;
|
||||||
|
else
|
||||||
|
nsites = 0;
|
||||||
|
|
||||||
if (nsites == 0) {
|
if (nsites == 0) {
|
||||||
error->all(FLERR, "Internal error: shake_flag[m] has to be between 1 and 4 for m in nlist");
|
error->all(FLERR, "Internal error: shake_flag[m] has to be between 1 and 4 for m in nlist");
|
||||||
@ -377,8 +366,7 @@ void FixEHEX::update_scalingmask() {
|
|||||||
// check atoms that do not belong to any cluster
|
// check atoms that do not belong to any cluster
|
||||||
|
|
||||||
for (int i = 0; i < atom->nlocal; i++) {
|
for (int i = 0; i < atom->nlocal; i++) {
|
||||||
if (fshake->shake_flag[i] == 0)
|
if (fshake->shake_flag[i] == 0) scalingmask[i] = rescale_atom(i, region);
|
||||||
scalingmask[i] = rescale_atom(i,region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -386,19 +374,17 @@ void FixEHEX::update_scalingmask() {
|
|||||||
// no clusters, just individual sites (e.g. monatomic system or flexible molecules)
|
// no clusters, just individual sites (e.g. monatomic system or flexible molecules)
|
||||||
|
|
||||||
else {
|
else {
|
||||||
for (int i=0; i<atom->nlocal; i++)
|
for (int i = 0; i < atom->nlocal; i++) scalingmask[i] = rescale_atom(i, region);
|
||||||
scalingmask[i] = rescale_atom(i,region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
Check if the centre of mass of the cluster to be constrained is
|
Check if the centre of mass of the cluster to be constrained is
|
||||||
inside the region.
|
inside the region.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
bool FixEHEX::check_cluster(tagint *shake_atom, int n, Region * region) {
|
bool FixEHEX::check_cluster(tagint *shake_atom, int n, Region *region)
|
||||||
|
{
|
||||||
|
|
||||||
// IMPORTANT NOTE: If any site of the cluster belongs to a group
|
// IMPORTANT NOTE: If any site of the cluster belongs to a group
|
||||||
// which should not be rescaled than all of the sites
|
// which should not be rescaled than all of the sites
|
||||||
@ -443,15 +429,13 @@ bool FixEHEX::check_cluster(tagint *shake_atom, int n, Region * region) {
|
|||||||
// NOTE: you can either use unwrapped coordinates or take site x[lid[0]] as reference,
|
// NOTE: you can either use unwrapped coordinates or take site x[lid[0]] as reference,
|
||||||
// i.e. reconstruct the molecule around this site and calculate the com.
|
// i.e. reconstruct the molecule around this site and calculate the com.
|
||||||
|
|
||||||
for (int k=0; k<3; k++)
|
for (int k = 0; k < 3; k++) xtemp[k] = x[lid[i]][k] - x[lid[0]][k];
|
||||||
xtemp[k] = x[lid[i]][k] - x[lid[0]][k];
|
|
||||||
|
|
||||||
// take into account pbc
|
// take into account pbc
|
||||||
|
|
||||||
domain->minimum_image(xtemp);
|
domain->minimum_image(xtemp);
|
||||||
|
|
||||||
for (int k=0; k<3; k++)
|
for (int k = 0; k < 3; k++) xcom[k] += mi * (x[lid[0]][k] + xtemp[k]);
|
||||||
xcom[k] += mi * (x[lid[0]][k] + xtemp[k]) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,14 +445,11 @@ bool FixEHEX::check_cluster(tagint *shake_atom, int n, Region * region) {
|
|||||||
|
|
||||||
// check mass
|
// check mass
|
||||||
|
|
||||||
if (mcluster < 1.e-14) {
|
if (mcluster < 1.e-14) { error->all(FLERR, "Fix ehex shake cluster has almost zero mass."); }
|
||||||
error->all(FLERR, "Fix ehex shake cluster has almost zero mass.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// divide by total mass
|
// divide by total mass
|
||||||
|
|
||||||
for (int k=0; k<3; k++)
|
for (int k = 0; k < 3; k++) xcom[k] = xcom[k] / mcluster;
|
||||||
xcom[k] = xcom[k]/mcluster;
|
|
||||||
|
|
||||||
// apply periodic boundary conditions (centre of mass could be outside the box)
|
// apply periodic boundary conditions (centre of mass could be outside the box)
|
||||||
// and check if molecule is inside the region
|
// and check if molecule is inside the region
|
||||||
@ -480,12 +461,12 @@ bool FixEHEX::check_cluster(tagint *shake_atom, int n, Region * region) {
|
|||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
Check if atom i has the correct group and is inside the region.
|
Check if atom i has the correct group and is inside the region.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
bool FixEHEX::rescale_atom(int i, Region*region) {
|
bool FixEHEX::rescale_atom(int i, Region *region)
|
||||||
|
{
|
||||||
bool stat;
|
bool stat;
|
||||||
double x_r[3];
|
double x_r[3];
|
||||||
|
|
||||||
@ -516,7 +497,9 @@ bool FixEHEX::rescale_atom(int i, Region*region) {
|
|||||||
(e.g. com velocity, kinetic energy, total mass,...)
|
(e.g. com velocity, kinetic energy, total mass,...)
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void FixEHEX::com_properties(double * vr, double * sfr, double *sfvr, double *K, double *Kr, double *mr) {
|
void FixEHEX::com_properties(double *vr, double *sfr, double *sfvr, double *K, double *Kr,
|
||||||
|
double *mr)
|
||||||
|
{
|
||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
double **v = atom->v;
|
double **v = atom->v;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
@ -586,9 +569,7 @@ void FixEHEX::com_properties(double * vr, double * sfr, double *sfvr, double *K,
|
|||||||
|
|
||||||
*mr = buf[4];
|
*mr = buf[4];
|
||||||
|
|
||||||
if (*mr < 1.e-14) {
|
if (*mr < 1.e-14) { error->all(FLERR, "Fix ehex error mass of region is close to zero"); }
|
||||||
error->all(FLERR, "Fix ehex error mass of region is close to zero");
|
|
||||||
}
|
|
||||||
|
|
||||||
// total kinetic energy of region
|
// total kinetic energy of region
|
||||||
|
|
||||||
@ -614,4 +595,3 @@ void FixEHEX::com_properties(double * vr, double * sfr, double *sfvr, double *K,
|
|||||||
|
|
||||||
*sfvr = buf[8] - (vr[0] * sfr[0] + vr[1] * sfr[1] + vr[2] * sfr[2]);
|
*sfvr = buf[8] - (vr[0] * sfr[0] + vr[1] * sfr[1] + vr[2] * sfr[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,10 +43,10 @@ class FixEHEX : public Fix {
|
|||||||
bool check_cluster(tagint *shake_atom, int n, class Region *region);
|
bool check_cluster(tagint *shake_atom, int n, class Region *region);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int iregion;
|
|
||||||
double heat_input;
|
double heat_input;
|
||||||
double masstotal;
|
double masstotal;
|
||||||
double scale;
|
double scale;
|
||||||
|
class Region *region;
|
||||||
char *idregion;
|
char *idregion;
|
||||||
int me;
|
int me;
|
||||||
|
|
||||||
|
|||||||
@ -108,7 +108,8 @@ class FixShake : public Fix {
|
|||||||
int nlist, maxlist; // size and max-size of list
|
int nlist, maxlist; // size and max-size of list
|
||||||
|
|
||||||
// stat quantities
|
// stat quantities
|
||||||
int *b_count, *b_count_all, *b_atom, *b_atom_all; // counts for each bond type, atoms in bond cluster
|
int *b_count, *b_count_all, *b_atom,
|
||||||
|
*b_atom_all; // counts for each bond type, atoms in bond cluster
|
||||||
double *b_ave, *b_max, *b_min; // ave/max/min dist for each bond type
|
double *b_ave, *b_max, *b_min; // ave/max/min dist for each bond type
|
||||||
double *b_ave_all, *b_max_all, *b_min_all; // MPI summing arrays
|
double *b_ave_all, *b_max_all, *b_min_all; // MPI summing arrays
|
||||||
int *a_count, *a_count_all; // ditto for angle types
|
int *a_count, *a_count_all; // ditto for angle types
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -23,14 +22,15 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "fix_setforce_spin.h"
|
#include "fix_setforce_spin.h"
|
||||||
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "update.h"
|
|
||||||
#include "modify.h"
|
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "region.h"
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "variable.h"
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "modify.h"
|
||||||
|
#include "region.h"
|
||||||
|
#include "update.h"
|
||||||
|
#include "variable.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
@ -39,8 +39,9 @@ enum{NONE,CONSTANT,EQUAL,ATOM};
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
FixSetForceSpin::FixSetForceSpin(LAMMPS *lmp, int narg, char **arg) :
|
FixSetForceSpin::FixSetForceSpin(LAMMPS *_lmp, int narg, char **arg) : FixSetForce(_lmp, narg, arg)
|
||||||
FixSetForce(lmp, narg, arg) {}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -53,11 +54,7 @@ void FixSetForceSpin::post_force(int /*vflag*/)
|
|||||||
|
|
||||||
// update region if necessary
|
// update region if necessary
|
||||||
|
|
||||||
Region *region = nullptr;
|
if (region) region->prematch();
|
||||||
if (iregion >= 0) {
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
|
||||||
}
|
|
||||||
|
|
||||||
// reallocate sforce array if necessary
|
// reallocate sforce array if necessary
|
||||||
|
|
||||||
@ -88,13 +85,16 @@ void FixSetForceSpin::post_force(int /*vflag*/)
|
|||||||
|
|
||||||
modify->clearstep_compute();
|
modify->clearstep_compute();
|
||||||
|
|
||||||
if (xstyle == EQUAL) xvalue = input->variable->compute_equal(xvar);
|
if (xstyle == EQUAL)
|
||||||
|
xvalue = input->variable->compute_equal(xvar);
|
||||||
else if (xstyle == ATOM)
|
else if (xstyle == ATOM)
|
||||||
input->variable->compute_atom(xvar, igroup, &sforce[0][0], 3, 0);
|
input->variable->compute_atom(xvar, igroup, &sforce[0][0], 3, 0);
|
||||||
if (ystyle == EQUAL) yvalue = input->variable->compute_equal(yvar);
|
if (ystyle == EQUAL)
|
||||||
|
yvalue = input->variable->compute_equal(yvar);
|
||||||
else if (ystyle == ATOM)
|
else if (ystyle == ATOM)
|
||||||
input->variable->compute_atom(yvar, igroup, &sforce[0][1], 3, 0);
|
input->variable->compute_atom(yvar, igroup, &sforce[0][1], 3, 0);
|
||||||
if (zstyle == EQUAL) zvalue = input->variable->compute_equal(zvar);
|
if (zstyle == EQUAL)
|
||||||
|
zvalue = input->variable->compute_equal(zvar);
|
||||||
else if (zstyle == ATOM)
|
else if (zstyle == ATOM)
|
||||||
input->variable->compute_atom(zvar, igroup, &sforce[0][2], 3, 0);
|
input->variable->compute_atom(zvar, igroup, &sforce[0][2], 3, 0);
|
||||||
|
|
||||||
@ -106,12 +106,18 @@ void FixSetForceSpin::post_force(int /*vflag*/)
|
|||||||
foriginal[0] += fm[i][0];
|
foriginal[0] += fm[i][0];
|
||||||
foriginal[1] += fm[i][1];
|
foriginal[1] += fm[i][1];
|
||||||
foriginal[2] += fm[i][2];
|
foriginal[2] += fm[i][2];
|
||||||
if (xstyle == ATOM) fm[i][0] = sforce[i][0];
|
if (xstyle == ATOM)
|
||||||
else if (xstyle) fm[i][0] = xvalue;
|
fm[i][0] = sforce[i][0];
|
||||||
if (ystyle == ATOM) fm[i][1] = sforce[i][1];
|
else if (xstyle)
|
||||||
else if (ystyle) fm[i][1] = yvalue;
|
fm[i][0] = xvalue;
|
||||||
if (zstyle == ATOM) fm[i][2] = sforce[i][2];
|
if (ystyle == ATOM)
|
||||||
else if (zstyle) fm[i][2] = zvalue;
|
fm[i][1] = sforce[i][1];
|
||||||
|
else if (ystyle)
|
||||||
|
fm[i][1] = yvalue;
|
||||||
|
if (zstyle == ATOM)
|
||||||
|
fm[i][2] = sforce[i][2];
|
||||||
|
else if (zstyle)
|
||||||
|
fm[i][2] = zvalue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,11 +131,7 @@ void FixSetForceSpin::single_setforce_spin(int i, double fmi[3])
|
|||||||
|
|
||||||
// update region if necessary
|
// update region if necessary
|
||||||
|
|
||||||
Region *region = nullptr;
|
if (region) region->prematch();
|
||||||
if (iregion >= 0) {
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
|
||||||
}
|
|
||||||
|
|
||||||
// reallocate sforce array if necessary
|
// reallocate sforce array if necessary
|
||||||
|
|
||||||
@ -161,13 +163,16 @@ void FixSetForceSpin::single_setforce_spin(int i, double fmi[3])
|
|||||||
|
|
||||||
modify->clearstep_compute();
|
modify->clearstep_compute();
|
||||||
|
|
||||||
if (xstyle == EQUAL) xvalue = input->variable->compute_equal(xvar);
|
if (xstyle == EQUAL)
|
||||||
|
xvalue = input->variable->compute_equal(xvar);
|
||||||
else if (xstyle == ATOM)
|
else if (xstyle == ATOM)
|
||||||
input->variable->compute_atom(xvar, igroup, &sforce[0][0], 3, 0);
|
input->variable->compute_atom(xvar, igroup, &sforce[0][0], 3, 0);
|
||||||
if (ystyle == EQUAL) yvalue = input->variable->compute_equal(yvar);
|
if (ystyle == EQUAL)
|
||||||
|
yvalue = input->variable->compute_equal(yvar);
|
||||||
else if (ystyle == ATOM)
|
else if (ystyle == ATOM)
|
||||||
input->variable->compute_atom(yvar, igroup, &sforce[0][1], 3, 0);
|
input->variable->compute_atom(yvar, igroup, &sforce[0][1], 3, 0);
|
||||||
if (zstyle == EQUAL) zvalue = input->variable->compute_equal(zvar);
|
if (zstyle == EQUAL)
|
||||||
|
zvalue = input->variable->compute_equal(zvar);
|
||||||
else if (zstyle == ATOM)
|
else if (zstyle == ATOM)
|
||||||
input->variable->compute_atom(zvar, igroup, &sforce[0][2], 3, 0);
|
input->variable->compute_atom(zvar, igroup, &sforce[0][2], 3, 0);
|
||||||
|
|
||||||
@ -178,12 +183,18 @@ void FixSetForceSpin::single_setforce_spin(int i, double fmi[3])
|
|||||||
foriginal[0] += fmi[0];
|
foriginal[0] += fmi[0];
|
||||||
foriginal[1] += fmi[1];
|
foriginal[1] += fmi[1];
|
||||||
foriginal[2] += fmi[2];
|
foriginal[2] += fmi[2];
|
||||||
if (xstyle == ATOM) fmi[0] = sforce[i][0];
|
if (xstyle == ATOM)
|
||||||
else if (xstyle) fmi[0] = xvalue;
|
fmi[0] = sforce[i][0];
|
||||||
if (ystyle == ATOM) fmi[1] = sforce[i][1];
|
else if (xstyle)
|
||||||
else if (ystyle) fmi[1] = yvalue;
|
fmi[0] = xvalue;
|
||||||
if (zstyle == ATOM) fmi[2] = sforce[i][2];
|
if (ystyle == ATOM)
|
||||||
else if (zstyle) fmi[2] = zvalue;
|
fmi[1] = sforce[i][1];
|
||||||
|
else if (ystyle)
|
||||||
|
fmi[1] = yvalue;
|
||||||
|
if (zstyle == ATOM)
|
||||||
|
fmi[2] = sforce[i][2];
|
||||||
|
else if (zstyle)
|
||||||
|
fmi[2] = zvalue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,13 +205,10 @@ void FixSetForceSpin::post_force_respa(int vflag, int ilevel, int /*iloop*/)
|
|||||||
{
|
{
|
||||||
// set force to desired value on requested level, 0.0 on other levels
|
// set force to desired value on requested level, 0.0 on other levels
|
||||||
|
|
||||||
if (ilevel == ilevel_respa) post_force(vflag);
|
if (ilevel == ilevel_respa)
|
||||||
|
post_force(vflag);
|
||||||
else {
|
else {
|
||||||
Region *region = nullptr;
|
if (region) region->prematch();
|
||||||
if (iregion >= 0) {
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
|
||||||
}
|
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
double **fm = atom->fm;
|
double **fm = atom->fm;
|
||||||
|
|||||||
@ -429,8 +429,7 @@ int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup)
|
|||||||
|
|
||||||
int MPI_Group_free(MPI_Group *group)
|
int MPI_Group_free(MPI_Group *group)
|
||||||
{
|
{
|
||||||
if (group)
|
if (group) *group = MPI_GROUP_NULL;
|
||||||
*group = MPI_GROUP_NULL;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,8 @@ class ComputeForceTally : public Compute {
|
|||||||
double memory_usage() override;
|
double memory_usage() override;
|
||||||
|
|
||||||
void pair_setup_callback(int, int) override;
|
void pair_setup_callback(int, int) override;
|
||||||
void pair_tally_callback(int, int, int, int, double, double, double, double, double, double) override;
|
void pair_tally_callback(int, int, int, int, double, double, double, double, double,
|
||||||
|
double) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bigint did_setup;
|
bigint did_setup;
|
||||||
|
|||||||
@ -39,7 +39,8 @@ class ComputeHeatFluxTally : public Compute {
|
|||||||
double memory_usage() override;
|
double memory_usage() override;
|
||||||
|
|
||||||
void pair_setup_callback(int, int) override;
|
void pair_setup_callback(int, int) override;
|
||||||
void pair_tally_callback(int, int, int, int, double, double, double, double, double, double) override;
|
void pair_tally_callback(int, int, int, int, double, double, double, double, double,
|
||||||
|
double) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bigint did_setup;
|
bigint did_setup;
|
||||||
|
|||||||
@ -40,7 +40,8 @@ class ComputeHeatFluxVirialTally : public Compute {
|
|||||||
double memory_usage() override;
|
double memory_usage() override;
|
||||||
|
|
||||||
void pair_setup_callback(int, int) override;
|
void pair_setup_callback(int, int) override;
|
||||||
void pair_tally_callback(int, int, int, int, double, double, double, double, double, double) override;
|
void pair_tally_callback(int, int, int, int, double, double, double, double, double,
|
||||||
|
double) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bigint did_setup;
|
bigint did_setup;
|
||||||
|
|||||||
@ -34,7 +34,8 @@ class ComputePEMolTally : public Compute {
|
|||||||
void compute_vector() override;
|
void compute_vector() override;
|
||||||
|
|
||||||
void pair_setup_callback(int, int) override;
|
void pair_setup_callback(int, int) override;
|
||||||
void pair_tally_callback(int, int, int, int, double, double, double, double, double, double) override;
|
void pair_tally_callback(int, int, int, int, double, double, double, double, double,
|
||||||
|
double) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bigint did_setup;
|
bigint did_setup;
|
||||||
|
|||||||
@ -40,7 +40,8 @@ class ComputePETally : public Compute {
|
|||||||
double memory_usage() override;
|
double memory_usage() override;
|
||||||
|
|
||||||
void pair_setup_callback(int, int) override;
|
void pair_setup_callback(int, int) override;
|
||||||
void pair_tally_callback(int, int, int, int, double, double, double, double, double, double) override;
|
void pair_tally_callback(int, int, int, int, double, double, double, double, double,
|
||||||
|
double) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bigint did_setup;
|
bigint did_setup;
|
||||||
|
|||||||
@ -40,7 +40,8 @@ class ComputeStressTally : public Compute {
|
|||||||
double memory_usage() override;
|
double memory_usage() override;
|
||||||
|
|
||||||
void pair_setup_callback(int, int) override;
|
void pair_setup_callback(int, int) override;
|
||||||
void pair_tally_callback(int, int, int, int, double, double, double, double, double, double) override;
|
void pair_tally_callback(int, int, int, int, double, double, double, double, double,
|
||||||
|
double) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bigint did_setup;
|
bigint did_setup;
|
||||||
|
|||||||
@ -246,12 +246,11 @@ void DumpVTK::init_style()
|
|||||||
else if (flag && cols) custom_flag[i] = DARRAY;
|
else if (flag && cols) custom_flag[i] = DARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set index and check validity of region
|
// check validity of region
|
||||||
|
|
||||||
if (iregion >= 0) {
|
if (idregion) {
|
||||||
iregion = domain->find_region(idregion);
|
if (!domain->get_region_by_id(idregion))
|
||||||
if (iregion == -1)
|
error->all(FLERR,"Region {} for dump vtk does not exist",idregion);
|
||||||
error->all(FLERR,"Region ID for dump vtk does not exist");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,8 +334,8 @@ int DumpVTK::count()
|
|||||||
|
|
||||||
// un-choose if not in region
|
// un-choose if not in region
|
||||||
|
|
||||||
if (iregion >= 0) {
|
auto region = domain->get_region_by_id(idregion);
|
||||||
Region *region = domain->regions[iregion];
|
if (region) {
|
||||||
region->prematch();
|
region->prematch();
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
@ -2054,11 +2053,12 @@ int DumpVTK::modify_param(int narg, char **arg)
|
|||||||
{
|
{
|
||||||
if (strcmp(arg[0],"region") == 0) {
|
if (strcmp(arg[0],"region") == 0) {
|
||||||
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
||||||
if (strcmp(arg[1],"none") == 0) iregion = -1;
|
if (strcmp(arg[1],"none") == 0) {
|
||||||
else {
|
delete[] idregion;
|
||||||
iregion = domain->find_region(arg[1]);
|
idregion = nullptr;
|
||||||
if (iregion == -1)
|
} else {
|
||||||
error->all(FLERR,"Dump_modify region ID {} does not exist",arg[1]);
|
if (!domain->get_region_by_id(arg[1]))
|
||||||
|
error->all(FLERR,"Dump_modify region {} does not exist",arg[1]);
|
||||||
delete[] idregion;
|
delete[] idregion;
|
||||||
idregion = utils::strdup(arg[1]);
|
idregion = utils::strdup(arg[1]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -361,8 +361,7 @@ double Angle::memory_usage()
|
|||||||
|
|
||||||
void Angle::reinit()
|
void Angle::reinit()
|
||||||
{
|
{
|
||||||
if (!reinitflag)
|
if (!reinitflag) error->all(FLERR, "Fix adapt interface to this angle style not supported");
|
||||||
error->all(FLERR, "Fix adapt interface to this angle style not supported");
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,7 +60,8 @@ class Angle : protected Pointers {
|
|||||||
virtual void read_restart_settings(FILE *){};
|
virtual void read_restart_settings(FILE *){};
|
||||||
virtual void write_data(FILE *) {}
|
virtual void write_data(FILE *) {}
|
||||||
virtual double single(int, int, int, int) = 0;
|
virtual double single(int, int, int, int) = 0;
|
||||||
virtual void born_matrix(int/*atype*/, int/*at1*/, int/*at2*/, int/*at3*/, double& du, double& du2)
|
virtual void born_matrix(int /*atype*/, int /*at1*/, int /*at2*/, int /*at3*/, double &du,
|
||||||
|
double &du2)
|
||||||
{
|
{
|
||||||
du = 0.0;
|
du = 0.0;
|
||||||
du2 = 0.0;
|
du2 = 0.0;
|
||||||
|
|||||||
@ -74,8 +74,8 @@ class AtomVecHybrid : public AtomVec {
|
|||||||
int nstyles_bonus;
|
int nstyles_bonus;
|
||||||
class AtomVec **styles_bonus;
|
class AtomVec **styles_bonus;
|
||||||
|
|
||||||
void merge_fields(std::vector<std::string> &, const std::vector<std::string> &,
|
void merge_fields(std::vector<std::string> &, const std::vector<std::string> &, int,
|
||||||
int, std::vector<std::string> &);
|
std::vector<std::string> &);
|
||||||
void build_styles();
|
void build_styles();
|
||||||
int known_style(char *);
|
int known_style(char *);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -46,6 +46,7 @@ class Balance : public Command {
|
|||||||
void dumpout(bigint);
|
void dumpout(bigint);
|
||||||
|
|
||||||
static constexpr int BSTR_SIZE = 3;
|
static constexpr int BSTR_SIZE = 3;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int me, nprocs;
|
int me, nprocs;
|
||||||
|
|
||||||
|
|||||||
@ -343,8 +343,7 @@ double Bond::memory_usage()
|
|||||||
|
|
||||||
void Bond::reinit()
|
void Bond::reinit()
|
||||||
{
|
{
|
||||||
if (!reinitflag)
|
if (!reinitflag) error->all(FLERR, "Fix adapt interface to this bond style not supported");
|
||||||
error->all(FLERR, "Fix adapt interface to this bond style not supported");
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,14 +64,15 @@ class Bond : protected Pointers {
|
|||||||
virtual double single(int, double, int, int, double &) = 0;
|
virtual double single(int, double, int, int, double &) = 0;
|
||||||
virtual double memory_usage();
|
virtual double memory_usage();
|
||||||
virtual void *extract(const char *, int &) { return nullptr; }
|
virtual void *extract(const char *, int &) { return nullptr; }
|
||||||
void reinit();
|
virtual void reinit();
|
||||||
|
|
||||||
virtual int pack_forward_comm(int, int *, double *, int, int *) { return 0; }
|
virtual int pack_forward_comm(int, int *, double *, int, int *) { return 0; }
|
||||||
virtual void unpack_forward_comm(int, int, double *) {}
|
virtual void unpack_forward_comm(int, int, double *) {}
|
||||||
virtual int pack_reverse_comm(int, int, double *) { return 0; }
|
virtual int pack_reverse_comm(int, int, double *) { return 0; }
|
||||||
virtual void unpack_reverse_comm(int, int *, double *) {}
|
virtual void unpack_reverse_comm(int, int *, double *) {}
|
||||||
|
|
||||||
virtual void born_matrix(int/*btype*/, double/*rsq*/, int/*at1*/, int/*at2*/, double& du, double& du2)
|
virtual void born_matrix(int /*btype*/, double /*rsq*/, int /*at1*/, int /*at2*/, double &du,
|
||||||
|
double &du2)
|
||||||
{
|
{
|
||||||
du = 0.0;
|
du = 0.0;
|
||||||
du2 = 0.0;
|
du2 = 0.0;
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -52,11 +51,10 @@ enum{LIMITMAX,LIMITEXACT};
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Compute(lmp, narg, arg),
|
Compute(lmp, narg, arg), chunk_volume_vec(nullptr), coord(nullptr), ichunk(nullptr),
|
||||||
chunk_volume_vec(nullptr), coord(nullptr), ichunk(nullptr), chunkID(nullptr),
|
chunkID(nullptr), cfvid(nullptr), idregion(nullptr), region(nullptr), cchunk(nullptr),
|
||||||
cfvid(nullptr), idregion(nullptr), region(nullptr), cchunk(nullptr), fchunk(nullptr),
|
fchunk(nullptr), varatom(nullptr), id_fix(nullptr), fixstore(nullptr), lockfix(nullptr),
|
||||||
varatom(nullptr), id_fix(nullptr), fixstore(nullptr), lockfix(nullptr), chunk(nullptr),
|
chunk(nullptr), exclude(nullptr), hash(nullptr)
|
||||||
exclude(nullptr), hash(nullptr)
|
|
||||||
{
|
{
|
||||||
if (narg < 4) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (narg < 4) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
|
|
||||||
@ -72,7 +70,6 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
binflag = 0;
|
binflag = 0;
|
||||||
ncoord = 0;
|
ncoord = 0;
|
||||||
cfvid = nullptr;
|
|
||||||
|
|
||||||
if (strcmp(arg[3], "bin/1d") == 0) {
|
if (strcmp(arg[3], "bin/1d") == 0) {
|
||||||
binflag = 1;
|
binflag = 1;
|
||||||
@ -153,8 +150,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
argindex = argi.get_index1();
|
argindex = argi.get_index1();
|
||||||
cfvid = argi.copy_name();
|
cfvid = argi.copy_name();
|
||||||
|
|
||||||
if ((which == ArgInfo::UNKNOWN) || (which == ArgInfo::NONE)
|
if ((which == ArgInfo::UNKNOWN) || (which == ArgInfo::NONE) || (argi.get_dim() > 1))
|
||||||
|| (argi.get_dim() > 1))
|
|
||||||
error->all(FLERR, "Illegal compute chunk/atom command");
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
iarg = 4;
|
iarg = 4;
|
||||||
}
|
}
|
||||||
@ -162,7 +158,6 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// optional args
|
// optional args
|
||||||
|
|
||||||
regionflag = 0;
|
regionflag = 0;
|
||||||
idregion = nullptr;
|
|
||||||
nchunksetflag = 0;
|
nchunksetflag = 0;
|
||||||
nchunkflag = EVERY;
|
nchunkflag = EVERY;
|
||||||
limit = 0;
|
limit = 0;
|
||||||
@ -184,17 +179,19 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg], "region") == 0) {
|
if (strcmp(arg[iarg], "region") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
int iregion = domain->find_region(arg[iarg+1]);
|
if (!domain->get_region_by_id(arg[iarg + 1]))
|
||||||
if (iregion == -1)
|
error->all(FLERR, "Region {} for compute chunk/atom does not exist", arg[iarg + 1]);
|
||||||
error->all(FLERR,"Region ID for compute chunk/atom does not exist");
|
|
||||||
idregion = utils::strdup(arg[iarg + 1]);
|
idregion = utils::strdup(arg[iarg + 1]);
|
||||||
regionflag = 1;
|
regionflag = 1;
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg], "nchunk") == 0) {
|
} else if (strcmp(arg[iarg], "nchunk") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (strcmp(arg[iarg+1],"once") == 0) nchunkflag = ONCE;
|
if (strcmp(arg[iarg + 1], "once") == 0)
|
||||||
else if (strcmp(arg[iarg+1],"every") == 0) nchunkflag = EVERY;
|
nchunkflag = ONCE;
|
||||||
else error->all(FLERR,"Illegal compute chunk/atom command");
|
else if (strcmp(arg[iarg + 1], "every") == 0)
|
||||||
|
nchunkflag = EVERY;
|
||||||
|
else
|
||||||
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
nchunksetflag = 1;
|
nchunksetflag = 1;
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg], "limit") == 0) {
|
} else if (strcmp(arg[iarg], "limit") == 0) {
|
||||||
@ -204,19 +201,25 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (limit && !compress) limitfirst = 1;
|
if (limit && !compress) limitfirst = 1;
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
if (limit) {
|
if (limit) {
|
||||||
if (iarg > narg)
|
if (iarg > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
|
if (strcmp(arg[iarg], "max") == 0)
|
||||||
|
limitstyle = LIMITMAX;
|
||||||
|
else if (strcmp(arg[iarg], "exact") == 0)
|
||||||
|
limitstyle = LIMITEXACT;
|
||||||
|
else
|
||||||
error->all(FLERR, "Illegal compute chunk/atom command");
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (strcmp(arg[iarg],"max") == 0) limitstyle = LIMITMAX;
|
|
||||||
else if (strcmp(arg[iarg],"exact") == 0) limitstyle = LIMITEXACT;
|
|
||||||
else error->all(FLERR,"Illegal compute chunk/atom command");
|
|
||||||
iarg++;
|
iarg++;
|
||||||
}
|
}
|
||||||
} else if (strcmp(arg[iarg], "ids") == 0) {
|
} else if (strcmp(arg[iarg], "ids") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (strcmp(arg[iarg+1],"once") == 0) idsflag = ONCE;
|
if (strcmp(arg[iarg + 1], "once") == 0)
|
||||||
else if (strcmp(arg[iarg+1],"nfreq") == 0) idsflag = NFREQ;
|
idsflag = ONCE;
|
||||||
else if (strcmp(arg[iarg+1],"every") == 0) idsflag = EVERY;
|
else if (strcmp(arg[iarg + 1], "nfreq") == 0)
|
||||||
else error->all(FLERR,"Illegal compute chunk/atom command");
|
idsflag = NFREQ;
|
||||||
|
else if (strcmp(arg[iarg + 1], "every") == 0)
|
||||||
|
idsflag = EVERY;
|
||||||
|
else
|
||||||
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg], "compress") == 0) {
|
} else if (strcmp(arg[iarg], "compress") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
@ -224,38 +227,55 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg], "discard") == 0) {
|
} else if (strcmp(arg[iarg], "discard") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (strcmp(arg[iarg+1],"mixed") == 0) discard = MIXED;
|
if (strcmp(arg[iarg + 1], "mixed") == 0)
|
||||||
else if (strcmp(arg[iarg+1],"no") == 0) discard = NODISCARD;
|
discard = MIXED;
|
||||||
else if (strcmp(arg[iarg+1],"yes") == 0) discard = YESDISCARD;
|
else if (strcmp(arg[iarg + 1], "no") == 0)
|
||||||
else error->all(FLERR,"Illegal compute chunk/atom command");
|
discard = NODISCARD;
|
||||||
|
else if (strcmp(arg[iarg + 1], "yes") == 0)
|
||||||
|
discard = YESDISCARD;
|
||||||
|
else
|
||||||
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
discardsetflag = 1;
|
discardsetflag = 1;
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg], "bound") == 0) {
|
} else if (strcmp(arg[iarg], "bound") == 0) {
|
||||||
if (iarg + 4 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (iarg + 4 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
int idim = 0;
|
int idim = 0;
|
||||||
if (strcmp(arg[iarg+1],"x") == 0) idim = 0;
|
if (strcmp(arg[iarg + 1], "x") == 0)
|
||||||
else if (strcmp(arg[iarg+1],"y") == 0) idim = 1;
|
idim = 0;
|
||||||
else if (strcmp(arg[iarg+1],"z") == 0) idim = 2;
|
else if (strcmp(arg[iarg + 1], "y") == 0)
|
||||||
else error->all(FLERR,"Illegal compute chunk/atom command");
|
idim = 1;
|
||||||
|
else if (strcmp(arg[iarg + 1], "z") == 0)
|
||||||
|
idim = 2;
|
||||||
|
else
|
||||||
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
minflag[idim] = COORD;
|
minflag[idim] = COORD;
|
||||||
if (strcmp(arg[iarg+2],"lower") == 0) minflag[idim] = LOWER;
|
if (strcmp(arg[iarg + 2], "lower") == 0)
|
||||||
else minvalue[idim] = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
minflag[idim] = LOWER;
|
||||||
|
else
|
||||||
|
minvalue[idim] = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
|
||||||
maxflag[idim] = COORD;
|
maxflag[idim] = COORD;
|
||||||
if (strcmp(arg[iarg+3],"upper") == 0) maxflag[idim] = UPPER;
|
if (strcmp(arg[iarg + 3], "upper") == 0)
|
||||||
else maxvalue[idim] = utils::numeric(FLERR,arg[iarg+3],false,lmp);
|
maxflag[idim] = UPPER;
|
||||||
|
else
|
||||||
|
maxvalue[idim] = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
|
||||||
iarg += 4;
|
iarg += 4;
|
||||||
} else if (strcmp(arg[iarg], "units") == 0) {
|
} else if (strcmp(arg[iarg], "units") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = BOX;
|
if (strcmp(arg[iarg + 1], "box") == 0)
|
||||||
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = LATTICE;
|
scaleflag = BOX;
|
||||||
else if (strcmp(arg[iarg+1],"reduced") == 0) scaleflag = REDUCED;
|
else if (strcmp(arg[iarg + 1], "lattice") == 0)
|
||||||
else error->all(FLERR,"Illegal compute chunk/atom command");
|
scaleflag = LATTICE;
|
||||||
|
else if (strcmp(arg[iarg + 1], "reduced") == 0)
|
||||||
|
scaleflag = REDUCED;
|
||||||
|
else
|
||||||
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg], "pbc") == 0) {
|
} else if (strcmp(arg[iarg], "pbc") == 0) {
|
||||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
pbcflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
pbcflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else error->all(FLERR,"Illegal compute chunk/atom command");
|
} else
|
||||||
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set nchunkflag and discard to default values if not explicitly set
|
// set nchunkflag and discard to default values if not explicitly set
|
||||||
@ -264,20 +284,26 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
if (!nchunksetflag) {
|
if (!nchunksetflag) {
|
||||||
if (binflag) {
|
if (binflag) {
|
||||||
if (scaleflag == REDUCED) nchunkflag = ONCE;
|
if (scaleflag == REDUCED)
|
||||||
else nchunkflag = EVERY;
|
nchunkflag = ONCE;
|
||||||
|
else
|
||||||
|
nchunkflag = EVERY;
|
||||||
}
|
}
|
||||||
if (which == ArgInfo::TYPE) nchunkflag = ONCE;
|
if (which == ArgInfo::TYPE) nchunkflag = ONCE;
|
||||||
if (which == ArgInfo::MOLECULE) {
|
if (which == ArgInfo::MOLECULE) {
|
||||||
if (regionflag) nchunkflag = EVERY;
|
if (regionflag)
|
||||||
else nchunkflag = ONCE;
|
nchunkflag = EVERY;
|
||||||
|
else
|
||||||
|
nchunkflag = ONCE;
|
||||||
}
|
}
|
||||||
if (compress) nchunkflag = EVERY;
|
if (compress) nchunkflag = EVERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!discardsetflag) {
|
if (!discardsetflag) {
|
||||||
if (binflag) discard = MIXED;
|
if (binflag)
|
||||||
else discard = YESDISCARD;
|
discard = MIXED;
|
||||||
|
else
|
||||||
|
discard = YESDISCARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error checks
|
// error checks
|
||||||
@ -286,7 +312,8 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
error->all(FLERR, "Compute chunk/atom molecule for non-molecular system");
|
error->all(FLERR, "Compute chunk/atom molecule for non-molecular system");
|
||||||
|
|
||||||
if (!binflag && discard == MIXED)
|
if (!binflag && discard == MIXED)
|
||||||
error->all(FLERR,"Compute chunk/atom without bins "
|
error->all(FLERR,
|
||||||
|
"Compute chunk/atom without bins "
|
||||||
"cannot use discard mixed");
|
"cannot use discard mixed");
|
||||||
if (which == ArgInfo::BIN1D && delta[0] <= 0.0)
|
if (which == ArgInfo::BIN1D && delta[0] <= 0.0)
|
||||||
error->all(FLERR, "Illegal compute chunk/atom command");
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
@ -294,11 +321,9 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
error->all(FLERR, "Illegal compute chunk/atom command");
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (which == ArgInfo::BIN2D && (dim[0] == dim[1]))
|
if (which == ArgInfo::BIN2D && (dim[0] == dim[1]))
|
||||||
error->all(FLERR, "Illegal compute chunk/atom command");
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (which == ArgInfo::BIN3D &&
|
if (which == ArgInfo::BIN3D && (delta[0] <= 0.0 || delta[1] <= 0.0 || delta[2] <= 0.0))
|
||||||
(delta[0] <= 0.0 || delta[1] <= 0.0 || delta[2] <= 0.0))
|
|
||||||
error->all(FLERR, "Illegal compute chunk/atom command");
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (which == ArgInfo::BIN3D &&
|
if (which == ArgInfo::BIN3D && (dim[0] == dim[1] || dim[1] == dim[2] || dim[0] == dim[2]))
|
||||||
(dim[0] == dim[1] || dim[1] == dim[2] || dim[0] == dim[2]))
|
|
||||||
error->all(FLERR, "Illegal compute chunk/atom command");
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (which == ArgInfo::BINSPHERE) {
|
if (which == ArgInfo::BINSPHERE) {
|
||||||
if (domain->dimension == 2 && sorigin_user[2] != 0.0)
|
if (domain->dimension == 2 && sorigin_user[2] != 0.0)
|
||||||
@ -307,8 +332,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
error->all(FLERR, "Illegal compute chunk/atom command");
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
}
|
}
|
||||||
if (which == ArgInfo::BINCYLINDER) {
|
if (which == ArgInfo::BINCYLINDER) {
|
||||||
if (delta[0] <= 0.0)
|
if (delta[0] <= 0.0) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
error->all(FLERR,"Illegal compute chunk/atom command");
|
|
||||||
if (domain->dimension == 2 && dim[0] != 2)
|
if (domain->dimension == 2 && dim[0] != 2)
|
||||||
error->all(FLERR, "Compute chunk/atom cylinder axis must be z for 2d");
|
error->all(FLERR, "Compute chunk/atom cylinder axis must be z for 2d");
|
||||||
if (cradmin_user < 0.0 || cradmin_user >= cradmax_user || ncbin < 1)
|
if (cradmin_user < 0.0 || cradmin_user >= cradmax_user || ncbin < 1)
|
||||||
@ -317,8 +341,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
if (which == ArgInfo::COMPUTE) {
|
if (which == ArgInfo::COMPUTE) {
|
||||||
cchunk = modify->get_compute_by_id(cfvid);
|
cchunk = modify->get_compute_by_id(cfvid);
|
||||||
if (!cchunk)
|
if (!cchunk) error->all(FLERR, "Compute ID {} for compute chunk /atom does not exist", cfvid);
|
||||||
error->all(FLERR,"Compute ID {} for compute chunk /atom does not exist",cfvid);
|
|
||||||
if (cchunk->peratom_flag == 0)
|
if (cchunk->peratom_flag == 0)
|
||||||
error->all(FLERR, "Compute chunk/atom compute does not calculate per-atom values");
|
error->all(FLERR, "Compute chunk/atom compute does not calculate per-atom values");
|
||||||
if ((argindex == 0) && (cchunk->size_peratom_cols != 0))
|
if ((argindex == 0) && (cchunk->size_peratom_cols != 0))
|
||||||
@ -331,8 +354,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
if (which == ArgInfo::FIX) {
|
if (which == ArgInfo::FIX) {
|
||||||
fchunk = modify->get_fix_by_id(cfvid);
|
fchunk = modify->get_fix_by_id(cfvid);
|
||||||
if (!fchunk)
|
if (!fchunk) error->all(FLERR, "Fix ID {} for compute chunk/atom does not exist", cfvid);
|
||||||
error->all(FLERR,"Fix ID {} for compute chunk/atom does not exist",cfvid);
|
|
||||||
if (fchunk->peratom_flag == 0)
|
if (fchunk->peratom_flag == 0)
|
||||||
error->all(FLERR, "Compute chunk/atom fix does not calculate per-atom values");
|
error->all(FLERR, "Compute chunk/atom fix does not calculate per-atom values");
|
||||||
if (argindex == 0 && fchunk->size_peratom_cols != 0)
|
if (argindex == 0 && fchunk->size_peratom_cols != 0)
|
||||||
@ -345,8 +367,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
if (which == ArgInfo::VARIABLE) {
|
if (which == ArgInfo::VARIABLE) {
|
||||||
int ivariable = input->variable->find(cfvid);
|
int ivariable = input->variable->find(cfvid);
|
||||||
if (ivariable < 0)
|
if (ivariable < 0) error->all(FLERR, "Variable name for compute chunk/atom does not exist");
|
||||||
error->all(FLERR,"Variable name for compute chunk/atom does not exist");
|
|
||||||
if (input->variable->atomstyle(ivariable) == 0)
|
if (input->variable->atomstyle(ivariable) == 0)
|
||||||
error->all(FLERR, "Compute chunk/atom variable is not atom-style variable");
|
error->all(FLERR, "Compute chunk/atom variable is not atom-style variable");
|
||||||
}
|
}
|
||||||
@ -362,21 +383,25 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
xscale = domain->lattice->xlattice;
|
xscale = domain->lattice->xlattice;
|
||||||
yscale = domain->lattice->ylattice;
|
yscale = domain->lattice->ylattice;
|
||||||
zscale = domain->lattice->zlattice;
|
zscale = domain->lattice->zlattice;
|
||||||
} else xscale = yscale = zscale = 1.0;
|
} else
|
||||||
|
xscale = yscale = zscale = 1.0;
|
||||||
|
|
||||||
// apply scaling factors and cylinder dims orthogonal to axis
|
// apply scaling factors and cylinder dims orthogonal to axis
|
||||||
|
|
||||||
if (binflag) {
|
if (binflag) {
|
||||||
double scale = 1.0;
|
double scale = 1.0;
|
||||||
if (which == ArgInfo::BIN1D || which == ArgInfo::BIN2D
|
if (which == ArgInfo::BIN1D || which == ArgInfo::BIN2D || which == ArgInfo::BIN3D ||
|
||||||
|| which == ArgInfo::BIN3D || which == ArgInfo::BINCYLINDER) {
|
which == ArgInfo::BINCYLINDER) {
|
||||||
if (which == ArgInfo::BIN1D || which == ArgInfo::BINCYLINDER) ndim = 1;
|
if (which == ArgInfo::BIN1D || which == ArgInfo::BINCYLINDER) ndim = 1;
|
||||||
if (which == ArgInfo::BIN2D) ndim = 2;
|
if (which == ArgInfo::BIN2D) ndim = 2;
|
||||||
if (which == ArgInfo::BIN3D) ndim = 3;
|
if (which == ArgInfo::BIN3D) ndim = 3;
|
||||||
for (int idim = 0; idim < ndim; idim++) {
|
for (int idim = 0; idim < ndim; idim++) {
|
||||||
if (dim[idim] == 0) scale = xscale;
|
if (dim[idim] == 0)
|
||||||
else if (dim[idim] == 1) scale = yscale;
|
scale = xscale;
|
||||||
else if (dim[idim] == 2) scale = zscale;
|
else if (dim[idim] == 1)
|
||||||
|
scale = yscale;
|
||||||
|
else if (dim[idim] == 2)
|
||||||
|
scale = zscale;
|
||||||
delta[idim] *= scale;
|
delta[idim] *= scale;
|
||||||
invdelta[idim] = 1.0 / delta[idim];
|
invdelta[idim] = 1.0 / delta[idim];
|
||||||
if (originflag[idim] == COORD) origin[idim] *= scale;
|
if (originflag[idim] == COORD) origin[idim] *= scale;
|
||||||
@ -426,8 +451,10 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// computeflag = 1 if this compute might invoke another compute
|
// computeflag = 1 if this compute might invoke another compute
|
||||||
// during assign_chunk_ids()
|
// during assign_chunk_ids()
|
||||||
|
|
||||||
if (which == ArgInfo::COMPUTE || which == ArgInfo::FIX || which == ArgInfo::VARIABLE) computeflag = 1;
|
if (which == ArgInfo::COMPUTE || which == ArgInfo::FIX || which == ArgInfo::VARIABLE)
|
||||||
else computeflag = 0;
|
computeflag = 1;
|
||||||
|
else
|
||||||
|
computeflag = 0;
|
||||||
|
|
||||||
// other initializations
|
// other initializations
|
||||||
|
|
||||||
@ -437,8 +464,10 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
id_fix = nullptr;
|
id_fix = nullptr;
|
||||||
fixstore = nullptr;
|
fixstore = nullptr;
|
||||||
|
|
||||||
if (compress) hash = new std::map<tagint,int>();
|
if (compress)
|
||||||
else hash = nullptr;
|
hash = new std::map<tagint, int>();
|
||||||
|
else
|
||||||
|
hash = nullptr;
|
||||||
|
|
||||||
maxvar = 0;
|
maxvar = 0;
|
||||||
varatom = nullptr;
|
varatom = nullptr;
|
||||||
@ -446,8 +475,10 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
lockcount = 0;
|
lockcount = 0;
|
||||||
lockfix = nullptr;
|
lockfix = nullptr;
|
||||||
|
|
||||||
if (which == ArgInfo::MOLECULE) molcheck = 1;
|
if (which == ArgInfo::MOLECULE)
|
||||||
else molcheck = 0;
|
molcheck = 1;
|
||||||
|
else
|
||||||
|
molcheck = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -480,26 +511,21 @@ void ComputeChunkAtom::init()
|
|||||||
// set and check validity of region
|
// set and check validity of region
|
||||||
|
|
||||||
if (regionflag) {
|
if (regionflag) {
|
||||||
int iregion = domain->find_region(idregion);
|
region = domain->get_region_by_id(idregion);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for compute chunk/atom does not exist", idregion);
|
||||||
error->all(FLERR,"Region ID for compute chunk/atom does not exist");
|
|
||||||
region = domain->regions[iregion];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set compute,fix,variable
|
// set compute,fix,variable
|
||||||
|
|
||||||
if (which == ArgInfo::COMPUTE) {
|
if (which == ArgInfo::COMPUTE) {
|
||||||
cchunk = modify->get_compute_by_id(cfvid);
|
cchunk = modify->get_compute_by_id(cfvid);
|
||||||
if (!cchunk)
|
if (!cchunk) error->all(FLERR, "Compute ID {} for compute chunk/atom does not exist", cfvid);
|
||||||
error->all(FLERR,"Compute ID {} for compute chunk/atom does not exist",cfvid);
|
|
||||||
} else if (which == ArgInfo::FIX) {
|
} else if (which == ArgInfo::FIX) {
|
||||||
fchunk = modify->get_fix_by_id(cfvid);
|
fchunk = modify->get_fix_by_id(cfvid);
|
||||||
if (!fchunk)
|
if (!fchunk) error->all(FLERR, "Fix ID {} for compute chunk/atom does not exist", cfvid);
|
||||||
error->all(FLERR,"Fix ID {} for compute chunk/atom does not exist",cfvid);
|
|
||||||
} else if (which == ArgInfo::VARIABLE) {
|
} else if (which == ArgInfo::VARIABLE) {
|
||||||
int ivariable = input->variable->find(cfvid);
|
int ivariable = input->variable->find(cfvid);
|
||||||
if (ivariable < 0)
|
if (ivariable < 0) error->all(FLERR, "Variable name for compute chunk/atom does not exist");
|
||||||
error->all(FLERR,"Variable name for compute chunk/atom does not exist");
|
|
||||||
vchunk = ivariable;
|
vchunk = ivariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,8 +540,7 @@ void ComputeChunkAtom::init()
|
|||||||
if (molecule[i] > maxone) maxone = molecule[i];
|
if (molecule[i] > maxone) maxone = molecule[i];
|
||||||
tagint maxall;
|
tagint maxall;
|
||||||
MPI_Allreduce(&maxone, &maxall, 1, MPI_LMP_TAGINT, MPI_MAX, world);
|
MPI_Allreduce(&maxone, &maxall, 1, MPI_LMP_TAGINT, MPI_MAX, world);
|
||||||
if (maxall > MAXSMALLINT)
|
if (maxall > MAXSMALLINT) error->all(FLERR, "Molecule IDs too large for compute chunk/atom");
|
||||||
error->all(FLERR,"Molecule IDs too large for compute chunk/atom");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for binning, if nchunkflag not already set, set it to ONCE or EVERY
|
// for binning, if nchunkflag not already set, set it to ONCE or EVERY
|
||||||
@ -526,7 +551,8 @@ void ComputeChunkAtom::init()
|
|||||||
if (domain->box_change_size == 0) {
|
if (domain->box_change_size == 0) {
|
||||||
if (nchunkflag == EVERY && invoked_setup >= 0) invoked_setup = -1;
|
if (nchunkflag == EVERY && invoked_setup >= 0) invoked_setup = -1;
|
||||||
nchunkflag = ONCE;
|
nchunkflag = ONCE;
|
||||||
} else nchunkflag = EVERY;
|
} else
|
||||||
|
nchunkflag = EVERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// require nchunkflag = ONCE if idsflag = ONCE
|
// require nchunkflag = ONCE if idsflag = ONCE
|
||||||
@ -545,8 +571,8 @@ void ComputeChunkAtom::init()
|
|||||||
|
|
||||||
if ((idsflag == ONCE || lockcount) && !fixstore) {
|
if ((idsflag == ONCE || lockcount) && !fixstore) {
|
||||||
id_fix = utils::strdup(id + std::string("_COMPUTE_STORE"));
|
id_fix = utils::strdup(id + std::string("_COMPUTE_STORE"));
|
||||||
fixstore = dynamic_cast<FixStore *>( modify->add_fix(fmt::format("{} {} STORE peratom 1 1",
|
fixstore = dynamic_cast<FixStore *>(
|
||||||
id_fix, group->names[igroup])));
|
modify->add_fix(fmt::format("{} {} STORE peratom 1 1", id_fix, group->names[igroup])));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((idsflag != ONCE && !lockcount) && fixstore) {
|
if ((idsflag != ONCE && !lockcount) && fixstore) {
|
||||||
@ -564,8 +590,10 @@ void ComputeChunkAtom::init()
|
|||||||
void ComputeChunkAtom::setup()
|
void ComputeChunkAtom::setup()
|
||||||
{
|
{
|
||||||
if (nchunkflag == ONCE) setup_chunks();
|
if (nchunkflag == ONCE) setup_chunks();
|
||||||
if (idsflag == ONCE) compute_ichunk();
|
if (idsflag == ONCE)
|
||||||
else invoked_ichunk = -1;
|
compute_ichunk();
|
||||||
|
else
|
||||||
|
invoked_ichunk = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -597,15 +625,13 @@ void ComputeChunkAtom::compute_peratom()
|
|||||||
for (int i = 0; i < nlocal; i++) chunk[i] = ichunk[i];
|
for (int i = 0; i < nlocal; i++) chunk[i] = ichunk[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
to return the number of chunks, we first need to make certain
|
to return the number of chunks, we first need to make certain
|
||||||
that compute_peratom() has been called.
|
that compute_peratom() has been called.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
double ComputeChunkAtom::compute_scalar()
|
double ComputeChunkAtom::compute_scalar()
|
||||||
{
|
{
|
||||||
if (invoked_peratom != update->ntimestep)
|
if (invoked_peratom != update->ntimestep) compute_peratom();
|
||||||
compute_peratom();
|
|
||||||
invoked_scalar = update->ntimestep;
|
invoked_scalar = update->ntimestep;
|
||||||
|
|
||||||
return (scalar = nchunk);
|
return (scalar = nchunk);
|
||||||
@ -631,7 +657,8 @@ void ComputeChunkAtom::lock(Fix *fixptr, bigint startstep, bigint stopstep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (startstep != lockstart || stopstep != lockstop)
|
if (startstep != lockstart || stopstep != lockstop)
|
||||||
error->all(FLERR,"Two fix commands using "
|
error->all(FLERR,
|
||||||
|
"Two fix commands using "
|
||||||
"same compute chunk/atom command in incompatible ways");
|
"same compute chunk/atom command in incompatible ways");
|
||||||
|
|
||||||
// set lock to last calling Fix, since it will be last to unlock()
|
// set lock to last calling Fix, since it will be last to unlock()
|
||||||
@ -695,20 +722,26 @@ void ComputeChunkAtom::compute_ichunk()
|
|||||||
if (binflag) {
|
if (binflag) {
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (exclude[i]) continue;
|
if (exclude[i]) continue;
|
||||||
if (hash->find(ichunk[i]) == hash->end()) exclude[i] = 1;
|
if (hash->find(ichunk[i]) == hash->end())
|
||||||
else ichunk[i] = hash->find(ichunk[i])->second;
|
exclude[i] = 1;
|
||||||
|
else
|
||||||
|
ichunk[i] = hash->find(ichunk[i])->second;
|
||||||
}
|
}
|
||||||
} else if (discard == NODISCARD) {
|
} else if (discard == NODISCARD) {
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (exclude[i]) continue;
|
if (exclude[i]) continue;
|
||||||
if (hash->find(ichunk[i]) == hash->end()) ichunk[i] = nchunk;
|
if (hash->find(ichunk[i]) == hash->end())
|
||||||
else ichunk[i] = hash->find(ichunk[i])->second;
|
ichunk[i] = nchunk;
|
||||||
|
else
|
||||||
|
ichunk[i] = hash->find(ichunk[i])->second;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (exclude[i]) continue;
|
if (exclude[i]) continue;
|
||||||
if (hash->find(ichunk[i]) == hash->end()) exclude[i] = 1;
|
if (hash->find(ichunk[i]) == hash->end())
|
||||||
else ichunk[i] = hash->find(ichunk[i])->second;
|
exclude[i] = 1;
|
||||||
|
else
|
||||||
|
ichunk[i] = hash->find(ichunk[i])->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -718,7 +751,8 @@ void ComputeChunkAtom::compute_ichunk()
|
|||||||
if (discard == NODISCARD) {
|
if (discard == NODISCARD) {
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (exclude[i]) continue;
|
if (exclude[i]) continue;
|
||||||
if (ichunk[i] < 1 || ichunk[i] > nchunk) ichunk[i] = nchunk;;
|
if (ichunk[i] < 1 || ichunk[i] > nchunk) ichunk[i] = nchunk;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
@ -776,8 +810,7 @@ int ComputeChunkAtom::setup_chunks()
|
|||||||
if (nchunkflag == ONCE && invoked_setup >= 0) flag = 1;
|
if (nchunkflag == ONCE && invoked_setup >= 0) flag = 1;
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (binflag && scaleflag == REDUCED && domain->box_change_size)
|
if (binflag && scaleflag == REDUCED && domain->box_change_size) bin_volumes();
|
||||||
bin_volumes();
|
|
||||||
return nchunk;
|
return nchunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,11 +823,12 @@ int ComputeChunkAtom::setup_chunks()
|
|||||||
// IDs are needed to scan for max ID and for compress()
|
// IDs are needed to scan for max ID and for compress()
|
||||||
|
|
||||||
if (binflag) {
|
if (binflag) {
|
||||||
if (which == ArgInfo::BIN1D || which == ArgInfo::BIN2D
|
if (which == ArgInfo::BIN1D || which == ArgInfo::BIN2D || which == ArgInfo::BIN3D)
|
||||||
|| which == ArgInfo::BIN3D)
|
|
||||||
nchunk = setup_xyz_bins();
|
nchunk = setup_xyz_bins();
|
||||||
else if (which == ArgInfo::BINSPHERE) nchunk = setup_sphere_bins();
|
else if (which == ArgInfo::BINSPHERE)
|
||||||
else if (which == ArgInfo::BINCYLINDER) nchunk = setup_cylinder_bins();
|
nchunk = setup_sphere_bins();
|
||||||
|
else if (which == ArgInfo::BINCYLINDER)
|
||||||
|
nchunk = setup_cylinder_bins();
|
||||||
bin_volumes();
|
bin_volumes();
|
||||||
} else {
|
} else {
|
||||||
chunk_volume_scalar = domain->xprd * domain->yprd;
|
chunk_volume_scalar = domain->xprd * domain->yprd;
|
||||||
@ -806,7 +840,8 @@ int ComputeChunkAtom::setup_chunks()
|
|||||||
// set nchunk for chunk styles other than binning
|
// set nchunk for chunk styles other than binning
|
||||||
// for styles other than TYPE, scan for max ID
|
// for styles other than TYPE, scan for max ID
|
||||||
|
|
||||||
if (which == ArgInfo::TYPE) nchunk = atom->ntypes;
|
if (which == ArgInfo::TYPE)
|
||||||
|
nchunk = atom->ntypes;
|
||||||
else if (!binflag) {
|
else if (!binflag) {
|
||||||
|
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
@ -826,8 +861,10 @@ int ComputeChunkAtom::setup_chunks()
|
|||||||
|
|
||||||
if (limit && !binflag) {
|
if (limit && !binflag) {
|
||||||
if (!compress) {
|
if (!compress) {
|
||||||
if (limitstyle == LIMITMAX) nchunk = MIN(nchunk,limit);
|
if (limitstyle == LIMITMAX)
|
||||||
else if (limitstyle == LIMITEXACT) nchunk = limit;
|
nchunk = MIN(nchunk, limit);
|
||||||
|
else if (limitstyle == LIMITEXACT)
|
||||||
|
nchunk = limit;
|
||||||
} else if (limitfirst) {
|
} else if (limitfirst) {
|
||||||
nchunk = MIN(nchunk, limit);
|
nchunk = MIN(nchunk, limit);
|
||||||
}
|
}
|
||||||
@ -836,8 +873,10 @@ int ComputeChunkAtom::setup_chunks()
|
|||||||
if (compress) compress_chunk_ids();
|
if (compress) compress_chunk_ids();
|
||||||
|
|
||||||
if (limit && !binflag && compress) {
|
if (limit && !binflag && compress) {
|
||||||
if (limitstyle == LIMITMAX) nchunk = MIN(nchunk,limit);
|
if (limitstyle == LIMITMAX)
|
||||||
else if (limitstyle == LIMITEXACT) nchunk = limit;
|
nchunk = MIN(nchunk, limit);
|
||||||
|
else if (limitstyle == LIMITEXACT)
|
||||||
|
nchunk = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nchunk;
|
return nchunk;
|
||||||
@ -878,14 +917,17 @@ void ComputeChunkAtom::assign_chunk_ids()
|
|||||||
|
|
||||||
if (regionflag) {
|
if (regionflag) {
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit &&
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
region->match(x[i][0],x[i][1],x[i][2])) exclude[i] = 0;
|
exclude[i] = 0;
|
||||||
else exclude[i] = 1;
|
else
|
||||||
|
exclude[i] = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < nlocal; i++) {
|
for (i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) exclude[i] = 0;
|
if (mask[i] & groupbit)
|
||||||
else exclude[i] = 1;
|
exclude[i] = 0;
|
||||||
|
else
|
||||||
|
exclude[i] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -893,11 +935,16 @@ void ComputeChunkAtom::assign_chunk_ids()
|
|||||||
// binning styles apply discard rule, others do not yet
|
// binning styles apply discard rule, others do not yet
|
||||||
|
|
||||||
if (binflag) {
|
if (binflag) {
|
||||||
if (which == ArgInfo::BIN1D) atom2bin1d();
|
if (which == ArgInfo::BIN1D)
|
||||||
else if (which == ArgInfo::BIN2D) atom2bin2d();
|
atom2bin1d();
|
||||||
else if (which == ArgInfo::BIN3D) atom2bin3d();
|
else if (which == ArgInfo::BIN2D)
|
||||||
else if (which == ArgInfo::BINSPHERE) atom2binsphere();
|
atom2bin2d();
|
||||||
else if (which == ArgInfo::BINCYLINDER) atom2bincylinder();
|
else if (which == ArgInfo::BIN3D)
|
||||||
|
atom2bin3d();
|
||||||
|
else if (which == ArgInfo::BINSPHERE)
|
||||||
|
atom2binsphere();
|
||||||
|
else if (which == ArgInfo::BINCYLINDER)
|
||||||
|
atom2bincylinder();
|
||||||
|
|
||||||
} else if (which == ArgInfo::TYPE) {
|
} else if (which == ArgInfo::TYPE) {
|
||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
@ -936,7 +983,8 @@ void ComputeChunkAtom::assign_chunk_ids()
|
|||||||
|
|
||||||
} else if (which == ArgInfo::FIX) {
|
} else if (which == ArgInfo::FIX) {
|
||||||
if (update->ntimestep % fchunk->peratom_freq)
|
if (update->ntimestep % fchunk->peratom_freq)
|
||||||
error->all(FLERR,"Fix used in compute chunk/atom not "
|
error->all(FLERR,
|
||||||
|
"Fix used in compute chunk/atom not "
|
||||||
"computed at compatible time");
|
"computed at compatible time");
|
||||||
|
|
||||||
if (argindex == 0) {
|
if (argindex == 0) {
|
||||||
@ -1010,8 +1058,7 @@ void ComputeChunkAtom::compress_chunk_ids()
|
|||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
std::map<tagint, int>::iterator pos;
|
std::map<tagint, int>::iterator pos;
|
||||||
for (pos = hash->begin(); pos != hash->end(); ++pos)
|
for (pos = hash->begin(); pos != hash->end(); ++pos) list[n++] = pos->first;
|
||||||
list[n++] = pos->first;
|
|
||||||
|
|
||||||
// if nall < 1M, just allgather all ID lists on every proc
|
// if nall < 1M, just allgather all ID lists on every proc
|
||||||
// else perform ring comm
|
// else perform ring comm
|
||||||
@ -1109,8 +1156,7 @@ void ComputeChunkAtom::check_molecules()
|
|||||||
|
|
||||||
if (!compress) {
|
if (!compress) {
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (molecule[i] > 0 && molecule[i] <= nchunk &&
|
if (molecule[i] > 0 && molecule[i] <= nchunk && ichunk[i] == 0) flag = 1;
|
||||||
ichunk[i] == 0) flag = 1;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int molid;
|
int molid;
|
||||||
@ -1123,8 +1169,7 @@ void ComputeChunkAtom::check_molecules()
|
|||||||
int flagall;
|
int flagall;
|
||||||
MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world);
|
MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world);
|
||||||
if (flagall && comm->me == 0)
|
if (flagall && comm->me == 0)
|
||||||
error->warning(FLERR,
|
error->warning(FLERR, "One or more chunks do not contain all atoms in molecule");
|
||||||
"One or more chunks do not contain all atoms in molecule");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
@ -1170,8 +1215,10 @@ int ComputeChunkAtom::setup_xyz_bins()
|
|||||||
|
|
||||||
for (m = 0; m < ndim; m++) {
|
for (m = 0; m < ndim; m++) {
|
||||||
idim = dim[m];
|
idim = dim[m];
|
||||||
if (originflag[m] == LOWER) origin[m] = binlo[idim];
|
if (originflag[m] == LOWER)
|
||||||
else if (originflag[m] == UPPER) origin[m] = binhi[idim];
|
origin[m] = binlo[idim];
|
||||||
|
else if (originflag[m] == UPPER)
|
||||||
|
origin[m] = binhi[idim];
|
||||||
else if (originflag[m] == CENTER)
|
else if (originflag[m] == CENTER)
|
||||||
origin[m] = 0.5 * (binlo[idim] + binhi[idim]);
|
origin[m] = 0.5 * (binlo[idim] + binhi[idim]);
|
||||||
|
|
||||||
@ -1205,8 +1252,7 @@ int ComputeChunkAtom::setup_xyz_bins()
|
|||||||
memory->create(coord, nbins, ndim, "chunk/atom:coord");
|
memory->create(coord, nbins, ndim, "chunk/atom:coord");
|
||||||
|
|
||||||
if (ndim == 1) {
|
if (ndim == 1) {
|
||||||
for (i = 0; i < nlayers[0]; i++)
|
for (i = 0; i < nlayers[0]; i++) coord[i][0] = offset[0] + (i + 0.5) * delta[0];
|
||||||
coord[i][0] = offset[0] + (i+0.5)*delta[0];
|
|
||||||
} else if (ndim == 2) {
|
} else if (ndim == 2) {
|
||||||
m = 0;
|
m = 0;
|
||||||
for (i = 0; i < nlayers[0]; i++) {
|
for (i = 0; i < nlayers[0]; i++) {
|
||||||
@ -1270,10 +1316,10 @@ int ComputeChunkAtom::setup_sphere_bins()
|
|||||||
int flag = 0;
|
int flag = 0;
|
||||||
if (periodicity[0] && sradmax > prd_half[0]) flag = 1;
|
if (periodicity[0] && sradmax > prd_half[0]) flag = 1;
|
||||||
if (periodicity[1] && sradmax > prd_half[1]) flag = 1;
|
if (periodicity[1] && sradmax > prd_half[1]) flag = 1;
|
||||||
if (domain->dimension == 3 &&
|
if (domain->dimension == 3 && periodicity[2] && sradmax > prd_half[2]) flag = 1;
|
||||||
periodicity[2] && sradmax > prd_half[2]) flag = 1;
|
|
||||||
if (flag)
|
if (flag)
|
||||||
error->all(FLERR,"Compute chunk/atom bin/sphere radius "
|
error->all(FLERR,
|
||||||
|
"Compute chunk/atom bin/sphere radius "
|
||||||
"is too large for periodic box");
|
"is too large for periodic box");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1336,7 +1382,8 @@ int ComputeChunkAtom::setup_cylinder_bins()
|
|||||||
if (periodicity[cdim1] && sradmax > prd_half[cdim1]) flag = 1;
|
if (periodicity[cdim1] && sradmax > prd_half[cdim1]) flag = 1;
|
||||||
if (periodicity[cdim2] && sradmax > prd_half[cdim2]) flag = 1;
|
if (periodicity[cdim2] && sradmax > prd_half[cdim2]) flag = 1;
|
||||||
if (flag)
|
if (flag)
|
||||||
error->all(FLERR,"Compute chunk/atom bin/cylinder radius "
|
error->all(FLERR,
|
||||||
|
"Compute chunk/atom bin/cylinder radius "
|
||||||
"is too large for periodic box");
|
"is too large for periodic box");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1384,16 +1431,17 @@ int ComputeChunkAtom::setup_cylinder_bins()
|
|||||||
|
|
||||||
void ComputeChunkAtom::bin_volumes()
|
void ComputeChunkAtom::bin_volumes()
|
||||||
{
|
{
|
||||||
if (which == ArgInfo::BIN1D || which == ArgInfo::BIN2D
|
if (which == ArgInfo::BIN1D || which == ArgInfo::BIN2D || which == ArgInfo::BIN3D) {
|
||||||
|| which == ArgInfo::BIN3D) {
|
|
||||||
if (domain->dimension == 3)
|
if (domain->dimension == 3)
|
||||||
chunk_volume_scalar = domain->xprd * domain->yprd * domain->zprd;
|
chunk_volume_scalar = domain->xprd * domain->yprd * domain->zprd;
|
||||||
else chunk_volume_scalar = domain->xprd * domain->yprd;
|
else
|
||||||
|
chunk_volume_scalar = domain->xprd * domain->yprd;
|
||||||
double *prd;
|
double *prd;
|
||||||
if (scaleflag == REDUCED) prd = domain->prd_lamda;
|
if (scaleflag == REDUCED)
|
||||||
else prd = domain->prd;
|
prd = domain->prd_lamda;
|
||||||
for (int m = 0; m < ndim; m++)
|
else
|
||||||
chunk_volume_scalar *= delta[m]/prd[dim[m]];
|
prd = domain->prd;
|
||||||
|
for (int m = 0; m < ndim; m++) chunk_volume_scalar *= delta[m] / prd[dim[m]];
|
||||||
|
|
||||||
} else if (which == ArgInfo::BINSPHERE) {
|
} else if (which == ArgInfo::BINSPHERE) {
|
||||||
memory->destroy(chunk_volume_vec);
|
memory->destroy(chunk_volume_vec);
|
||||||
@ -1415,8 +1463,10 @@ void ComputeChunkAtom::bin_volumes()
|
|||||||
// slabthick = delta of bins along cylinder axis
|
// slabthick = delta of bins along cylinder axis
|
||||||
|
|
||||||
double *prd;
|
double *prd;
|
||||||
if (scaleflag == REDUCED) prd = domain->prd_lamda;
|
if (scaleflag == REDUCED)
|
||||||
else prd = domain->prd;
|
prd = domain->prd_lamda;
|
||||||
|
else
|
||||||
|
prd = domain->prd;
|
||||||
double slabthick = domain->prd[dim[0]] * delta[0] / prd[dim[0]];
|
double slabthick = domain->prd[dim[0]] * delta[0] / prd[dim[0]];
|
||||||
|
|
||||||
// area lo/hi of concentric circles in radial direction
|
// area lo/hi of concentric circles in radial direction
|
||||||
@ -1483,12 +1533,14 @@ void ComputeChunkAtom::atom2bin1d()
|
|||||||
if (xremap < offset[0]) ibin--;
|
if (xremap < offset[0]) ibin--;
|
||||||
|
|
||||||
if (discard == MIXED) {
|
if (discard == MIXED) {
|
||||||
if (!minflag[idim]) ibin = MAX(ibin,0);
|
if (!minflag[idim])
|
||||||
|
ibin = MAX(ibin, 0);
|
||||||
else if (ibin < 0) {
|
else if (ibin < 0) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!maxflag[idim]) ibin = MIN(ibin,nlayer1m1);
|
if (!maxflag[idim])
|
||||||
|
ibin = MIN(ibin, nlayer1m1);
|
||||||
else if (ibin > nlayer1m1) {
|
else if (ibin > nlayer1m1) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -1557,12 +1609,14 @@ void ComputeChunkAtom::atom2bin2d()
|
|||||||
if (xremap < offset[0]) i1bin--;
|
if (xremap < offset[0]) i1bin--;
|
||||||
|
|
||||||
if (discard == MIXED) {
|
if (discard == MIXED) {
|
||||||
if (!minflag[idim]) i1bin = MAX(i1bin,0);
|
if (!minflag[idim])
|
||||||
|
i1bin = MAX(i1bin, 0);
|
||||||
else if (i1bin < 0) {
|
else if (i1bin < 0) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!maxflag[idim]) i1bin = MIN(i1bin,nlayer1m1);
|
if (!maxflag[idim])
|
||||||
|
i1bin = MIN(i1bin, nlayer1m1);
|
||||||
else if (i1bin > nlayer1m1) {
|
else if (i1bin > nlayer1m1) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -1585,12 +1639,14 @@ void ComputeChunkAtom::atom2bin2d()
|
|||||||
if (yremap < offset[1]) i2bin--;
|
if (yremap < offset[1]) i2bin--;
|
||||||
|
|
||||||
if (discard == MIXED) {
|
if (discard == MIXED) {
|
||||||
if (!minflag[jdim]) i2bin = MAX(i2bin,0);
|
if (!minflag[jdim])
|
||||||
|
i2bin = MAX(i2bin, 0);
|
||||||
else if (i2bin < 0) {
|
else if (i2bin < 0) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!maxflag[jdim]) i2bin = MIN(i2bin,nlayer2m1);
|
if (!maxflag[jdim])
|
||||||
|
i2bin = MIN(i2bin, nlayer2m1);
|
||||||
else if (i2bin > nlayer2m1) {
|
else if (i2bin > nlayer2m1) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -1662,12 +1718,14 @@ void ComputeChunkAtom::atom2bin3d()
|
|||||||
if (xremap < offset[0]) i1bin--;
|
if (xremap < offset[0]) i1bin--;
|
||||||
|
|
||||||
if (discard == MIXED) {
|
if (discard == MIXED) {
|
||||||
if (!minflag[idim]) i1bin = MAX(i1bin,0);
|
if (!minflag[idim])
|
||||||
|
i1bin = MAX(i1bin, 0);
|
||||||
else if (i1bin < 0) {
|
else if (i1bin < 0) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!maxflag[idim]) i1bin = MIN(i1bin,nlayer1m1);
|
if (!maxflag[idim])
|
||||||
|
i1bin = MIN(i1bin, nlayer1m1);
|
||||||
else if (i1bin > nlayer1m1) {
|
else if (i1bin > nlayer1m1) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -1690,12 +1748,14 @@ void ComputeChunkAtom::atom2bin3d()
|
|||||||
if (yremap < offset[1]) i2bin--;
|
if (yremap < offset[1]) i2bin--;
|
||||||
|
|
||||||
if (discard == MIXED) {
|
if (discard == MIXED) {
|
||||||
if (!minflag[jdim]) i2bin = MAX(i2bin,0);
|
if (!minflag[jdim])
|
||||||
|
i2bin = MAX(i2bin, 0);
|
||||||
else if (i2bin < 0) {
|
else if (i2bin < 0) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!maxflag[jdim]) i2bin = MIN(i2bin,nlayer2m1);
|
if (!maxflag[jdim])
|
||||||
|
i2bin = MIN(i2bin, nlayer2m1);
|
||||||
else if (i2bin > nlayer2m1) {
|
else if (i2bin > nlayer2m1) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -1718,12 +1778,14 @@ void ComputeChunkAtom::atom2bin3d()
|
|||||||
if (zremap < offset[2]) i3bin--;
|
if (zremap < offset[2]) i3bin--;
|
||||||
|
|
||||||
if (discard == MIXED) {
|
if (discard == MIXED) {
|
||||||
if (!minflag[kdim]) i3bin = MAX(i3bin,0);
|
if (!minflag[kdim])
|
||||||
|
i3bin = MAX(i3bin, 0);
|
||||||
else if (i3bin < 0) {
|
else if (i3bin < 0) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!maxflag[kdim]) i3bin = MIN(i3bin,nlayer3m1);
|
if (!maxflag[kdim])
|
||||||
|
i3bin = MIN(i3bin, nlayer3m1);
|
||||||
else if (i3bin > nlayer3m1) {
|
else if (i3bin > nlayer3m1) {
|
||||||
exclude[i] = 1;
|
exclude[i] = 1;
|
||||||
continue;
|
continue;
|
||||||
@ -1796,20 +1858,26 @@ void ComputeChunkAtom::atom2binsphere()
|
|||||||
if (pbcflag) {
|
if (pbcflag) {
|
||||||
if (periodicity[0]) {
|
if (periodicity[0]) {
|
||||||
while (fabs(dx) > prd_half[0]) {
|
while (fabs(dx) > prd_half[0]) {
|
||||||
if (dx < 0.0) dx += prd[0];
|
if (dx < 0.0)
|
||||||
else dx -= prd[0];
|
dx += prd[0];
|
||||||
|
else
|
||||||
|
dx -= prd[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (periodicity[1]) {
|
if (periodicity[1]) {
|
||||||
while (fabs(dy) > prd_half[1]) {
|
while (fabs(dy) > prd_half[1]) {
|
||||||
if (dy < 0.0) dy += prd[1];
|
if (dy < 0.0)
|
||||||
else dy -= prd[1];
|
dy += prd[1];
|
||||||
|
else
|
||||||
|
dy -= prd[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (periodicity[2]) {
|
if (periodicity[2]) {
|
||||||
while (fabs(dz) > prd_half[2]) {
|
while (fabs(dz) > prd_half[2]) {
|
||||||
if (dz < 0.0) dz += prd[2];
|
if (dz < 0.0)
|
||||||
else dz -= prd[2];
|
dz += prd[2];
|
||||||
|
else
|
||||||
|
dz -= prd[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1886,14 +1954,18 @@ void ComputeChunkAtom::atom2bincylinder()
|
|||||||
if (pbcflag) {
|
if (pbcflag) {
|
||||||
if (periodicity[cdim1]) {
|
if (periodicity[cdim1]) {
|
||||||
if (fabs(d1) > prd_half[cdim1]) {
|
if (fabs(d1) > prd_half[cdim1]) {
|
||||||
if (d1 < 0.0) d1 += prd[cdim1];
|
if (d1 < 0.0)
|
||||||
else d1 -= prd[cdim1];
|
d1 += prd[cdim1];
|
||||||
|
else
|
||||||
|
d1 -= prd[cdim1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (periodicity[cdim2]) {
|
if (periodicity[cdim2]) {
|
||||||
if (fabs(d2) > prd_half[cdim2]) {
|
if (fabs(d2) > prd_half[cdim2]) {
|
||||||
if (d2 < 0.0) d2 += prd[cdim2];
|
if (d2 < 0.0)
|
||||||
else d2 -= prd[cdim2];
|
d2 += prd[cdim2];
|
||||||
|
else
|
||||||
|
d2 -= prd[cdim2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1925,20 +1997,27 @@ void ComputeChunkAtom::atom2bincylinder()
|
|||||||
void ComputeChunkAtom::readdim(int narg, char **arg, int iarg, int idim)
|
void ComputeChunkAtom::readdim(int narg, char **arg, int iarg, int idim)
|
||||||
{
|
{
|
||||||
if (narg < iarg + 3) error->all(FLERR, "Illegal compute chunk/atom command");
|
if (narg < iarg + 3) error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
if (strcmp(arg[iarg],"x") == 0) dim[idim] = 0;
|
if (strcmp(arg[iarg], "x") == 0)
|
||||||
else if (strcmp(arg[iarg],"y") == 0) dim[idim] = 1;
|
dim[idim] = 0;
|
||||||
else if (strcmp(arg[iarg],"z") == 0) dim[idim] = 2;
|
else if (strcmp(arg[iarg], "y") == 0)
|
||||||
else error->all(FLERR,"Illegal compute chunk/atom command");
|
dim[idim] = 1;
|
||||||
|
else if (strcmp(arg[iarg], "z") == 0)
|
||||||
|
dim[idim] = 2;
|
||||||
|
else
|
||||||
|
error->all(FLERR, "Illegal compute chunk/atom command");
|
||||||
|
|
||||||
if (dim[idim] == 2 && domain->dimension == 2)
|
if (dim[idim] == 2 && domain->dimension == 2)
|
||||||
error->all(FLERR, "Cannot use compute chunk/atom bin z for 2d model");
|
error->all(FLERR, "Cannot use compute chunk/atom bin z for 2d model");
|
||||||
|
|
||||||
if (strcmp(arg[iarg+1],"lower") == 0) originflag[idim] = LOWER;
|
if (strcmp(arg[iarg + 1], "lower") == 0)
|
||||||
else if (strcmp(arg[iarg+1],"center") == 0) originflag[idim] = CENTER;
|
originflag[idim] = LOWER;
|
||||||
else if (strcmp(arg[iarg+1],"upper") == 0) originflag[idim] = UPPER;
|
else if (strcmp(arg[iarg + 1], "center") == 0)
|
||||||
else originflag[idim] = COORD;
|
originflag[idim] = CENTER;
|
||||||
if (originflag[idim] == COORD)
|
else if (strcmp(arg[iarg + 1], "upper") == 0)
|
||||||
origin[idim] = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
originflag[idim] = UPPER;
|
||||||
|
else
|
||||||
|
originflag[idim] = COORD;
|
||||||
|
if (originflag[idim] == COORD) origin[idim] = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
|
||||||
|
|
||||||
delta[idim] = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
|
delta[idim] = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -184,8 +184,8 @@ void ComputeClusterAtom::compute_peratom()
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
int ComputeClusterAtom::pack_forward_comm(int n, int *list, double *buf,
|
int ComputeClusterAtom::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
|
||||||
int /*pbc_flag*/, int * /*pbc*/)
|
int * /*pbc*/)
|
||||||
{
|
{
|
||||||
int i, j, m;
|
int i, j, m;
|
||||||
|
|
||||||
|
|||||||
@ -311,8 +311,8 @@ void ComputeCoordAtom::compute_peratom()
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
int ComputeCoordAtom::pack_forward_comm(int n, int *list, double *buf,
|
int ComputeCoordAtom::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
|
||||||
int /*pbc_flag*/, int * /*pbc*/)
|
int * /*pbc*/)
|
||||||
{
|
{
|
||||||
int i, m = 0, j;
|
int i, m = 0, j;
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
|
|||||||
@ -63,8 +63,8 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, a
|
|||||||
// id = compute-ID + COMPUTE_STORE, fix group = compute group
|
// id = compute-ID + COMPUTE_STORE, fix group = compute group
|
||||||
|
|
||||||
id_fix = utils::strdup(id + std::string("_COMPUTE_STORE"));
|
id_fix = utils::strdup(id + std::string("_COMPUTE_STORE"));
|
||||||
fix = dynamic_cast<FixStore *>( modify->add_fix(
|
fix = dynamic_cast<FixStore *>(
|
||||||
fmt::format("{} {} STORE peratom 1 3", id_fix, group->names[igroup])));
|
modify->add_fix(fmt::format("{} {} STORE peratom 1 3", id_fix, group->names[igroup])));
|
||||||
|
|
||||||
// calculate xu,yu,zu for fix store array
|
// calculate xu,yu,zu for fix store array
|
||||||
// skip if reset from restart file
|
// skip if reset from restart file
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -35,32 +34,36 @@ using namespace LAMMPS_NS;
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
||||||
Compute(lmp, narg, arg),
|
Compute(lmp, narg, arg), nvalues(0), which(nullptr), argindex(nullptr), flavor(nullptr),
|
||||||
nvalues(0), which(nullptr), argindex(nullptr), flavor(nullptr),
|
|
||||||
value2index(nullptr), ids(nullptr), onevec(nullptr), replace(nullptr), indices(nullptr),
|
value2index(nullptr), ids(nullptr), onevec(nullptr), replace(nullptr), indices(nullptr),
|
||||||
owner(nullptr), idregion(nullptr), varatom(nullptr)
|
owner(nullptr), idregion(nullptr), region(nullptr), varatom(nullptr)
|
||||||
{
|
{
|
||||||
int iarg = 0;
|
int iarg = 0;
|
||||||
if (strcmp(style, "reduce") == 0) {
|
if (strcmp(style, "reduce") == 0) {
|
||||||
if (narg < 5) error->all(FLERR, "Illegal compute reduce command");
|
if (narg < 5) error->all(FLERR, "Illegal compute reduce command");
|
||||||
idregion = nullptr;
|
|
||||||
iarg = 3;
|
iarg = 3;
|
||||||
} else if (strcmp(style, "reduce/region") == 0) {
|
} else if (strcmp(style, "reduce/region") == 0) {
|
||||||
if (narg < 6) error->all(FLERR, "Illegal compute reduce/region command");
|
if (narg < 6) error->all(FLERR, "Illegal compute reduce/region command");
|
||||||
iregion = domain->find_region(arg[3]);
|
if (!domain->get_region_by_id(arg[3]))
|
||||||
if (iregion == -1)
|
error->all(FLERR, "Region {} for compute reduce/region does not exist", arg[3]);
|
||||||
error->all(FLERR,"Region ID for compute reduce/region does not exist");
|
|
||||||
idregion = utils::strdup(arg[3]);
|
idregion = utils::strdup(arg[3]);
|
||||||
iarg = 4;
|
iarg = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(arg[iarg],"sum") == 0) mode = SUM;
|
if (strcmp(arg[iarg], "sum") == 0)
|
||||||
else if (strcmp(arg[iarg],"sumsq") == 0) mode = SUMSQ;
|
mode = SUM;
|
||||||
else if (strcmp(arg[iarg],"min") == 0) mode = MINN;
|
else if (strcmp(arg[iarg], "sumsq") == 0)
|
||||||
else if (strcmp(arg[iarg],"max") == 0) mode = MAXX;
|
mode = SUMSQ;
|
||||||
else if (strcmp(arg[iarg],"ave") == 0) mode = AVE;
|
else if (strcmp(arg[iarg], "min") == 0)
|
||||||
else if (strcmp(arg[iarg],"avesq") == 0) mode = AVESQ;
|
mode = MINN;
|
||||||
else error->all(FLERR,"Illegal compute reduce command");
|
else if (strcmp(arg[iarg], "max") == 0)
|
||||||
|
mode = MAXX;
|
||||||
|
else if (strcmp(arg[iarg], "ave") == 0)
|
||||||
|
mode = AVE;
|
||||||
|
else if (strcmp(arg[iarg], "avesq") == 0)
|
||||||
|
mode = AVESQ;
|
||||||
|
else
|
||||||
|
error->all(FLERR, "Illegal compute {} operation {}", style, arg[iarg]);
|
||||||
iarg++;
|
iarg++;
|
||||||
|
|
||||||
MPI_Comm_rank(world, &me);
|
MPI_Comm_rank(world, &me);
|
||||||
@ -158,7 +161,8 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
error->all(FLERR, "Invalid replace values in compute reduce");
|
error->all(FLERR, "Invalid replace values in compute reduce");
|
||||||
replace[col1] = col2;
|
replace[col1] = col2;
|
||||||
iarg += 3;
|
iarg += 3;
|
||||||
} else error->all(FLERR,"Illegal compute reduce command");
|
} else
|
||||||
|
error->all(FLERR, "Illegal compute reduce command");
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete replace if not set
|
// delete replace if not set
|
||||||
@ -186,41 +190,37 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
else if (which[i] == ArgInfo::COMPUTE) {
|
else if (which[i] == ArgInfo::COMPUTE) {
|
||||||
int icompute = modify->find_compute(ids[i]);
|
int icompute = modify->find_compute(ids[i]);
|
||||||
if (icompute < 0)
|
if (icompute < 0) error->all(FLERR, "Compute ID for compute reduce does not exist");
|
||||||
error->all(FLERR,"Compute ID for compute reduce does not exist");
|
|
||||||
if (modify->compute[icompute]->peratom_flag) {
|
if (modify->compute[icompute]->peratom_flag) {
|
||||||
flavor[i] = PERATOM;
|
flavor[i] = PERATOM;
|
||||||
if (argindex[i] == 0 &&
|
if (argindex[i] == 0 && modify->compute[icompute]->size_peratom_cols != 0)
|
||||||
modify->compute[icompute]->size_peratom_cols != 0)
|
error->all(FLERR,
|
||||||
error->all(FLERR,"Compute reduce compute does not "
|
"Compute reduce compute does not "
|
||||||
"calculate a per-atom vector");
|
"calculate a per-atom vector");
|
||||||
if (argindex[i] && modify->compute[icompute]->size_peratom_cols == 0)
|
if (argindex[i] && modify->compute[icompute]->size_peratom_cols == 0)
|
||||||
error->all(FLERR,"Compute reduce compute does not "
|
|
||||||
"calculate a per-atom array");
|
|
||||||
if (argindex[i] &&
|
|
||||||
argindex[i] > modify->compute[icompute]->size_peratom_cols)
|
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Compute reduce compute array is accessed out-of-range");
|
"Compute reduce compute does not "
|
||||||
|
"calculate a per-atom array");
|
||||||
|
if (argindex[i] && argindex[i] > modify->compute[icompute]->size_peratom_cols)
|
||||||
|
error->all(FLERR, "Compute reduce compute array is accessed out-of-range");
|
||||||
} else if (modify->compute[icompute]->local_flag) {
|
} else if (modify->compute[icompute]->local_flag) {
|
||||||
flavor[i] = LOCAL;
|
flavor[i] = LOCAL;
|
||||||
if (argindex[i] == 0 &&
|
if (argindex[i] == 0 && modify->compute[icompute]->size_local_cols != 0)
|
||||||
modify->compute[icompute]->size_local_cols != 0)
|
error->all(FLERR,
|
||||||
error->all(FLERR,"Compute reduce compute does not "
|
"Compute reduce compute does not "
|
||||||
"calculate a local vector");
|
"calculate a local vector");
|
||||||
if (argindex[i] && modify->compute[icompute]->size_local_cols == 0)
|
if (argindex[i] && modify->compute[icompute]->size_local_cols == 0)
|
||||||
error->all(FLERR,"Compute reduce compute does not "
|
|
||||||
"calculate a local array");
|
|
||||||
if (argindex[i] &&
|
|
||||||
argindex[i] > modify->compute[icompute]->size_local_cols)
|
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Compute reduce compute array is accessed out-of-range");
|
"Compute reduce compute does not "
|
||||||
} else error->all(FLERR,
|
"calculate a local array");
|
||||||
"Compute reduce compute calculates global values");
|
if (argindex[i] && argindex[i] > modify->compute[icompute]->size_local_cols)
|
||||||
|
error->all(FLERR, "Compute reduce compute array is accessed out-of-range");
|
||||||
|
} else
|
||||||
|
error->all(FLERR, "Compute reduce compute calculates global values");
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::FIX) {
|
} else if (which[i] == ArgInfo::FIX) {
|
||||||
auto ifix = modify->get_fix_by_id(ids[i]);
|
auto ifix = modify->get_fix_by_id(ids[i]);
|
||||||
if (!ifix)
|
if (!ifix) error->all(FLERR, "Fix ID {} for compute reduce does not exist", ids[i]);
|
||||||
error->all(FLERR,"Fix ID {} for compute reduce does not exist", ids[i]);
|
|
||||||
if (ifix->peratom_flag) {
|
if (ifix->peratom_flag) {
|
||||||
flavor[i] = PERATOM;
|
flavor[i] = PERATOM;
|
||||||
if (argindex[i] == 0 && (ifix->size_peratom_cols != 0))
|
if (argindex[i] == 0 && (ifix->size_peratom_cols != 0))
|
||||||
@ -237,12 +237,12 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
error->all(FLERR, "Compute reduce fix {} does not calculate a local array", ids[i]);
|
error->all(FLERR, "Compute reduce fix {} does not calculate a local array", ids[i]);
|
||||||
if (argindex[i] && (argindex[i] > ifix->size_local_cols))
|
if (argindex[i] && (argindex[i] > ifix->size_local_cols))
|
||||||
error->all(FLERR, "Compute reduce fix {} array is accessed out-of-range", ids[i]);
|
error->all(FLERR, "Compute reduce fix {} array is accessed out-of-range", ids[i]);
|
||||||
} else error->all(FLERR,"Compute reduce fix {} calculates global values", ids[i]);
|
} else
|
||||||
|
error->all(FLERR, "Compute reduce fix {} calculates global values", ids[i]);
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::VARIABLE) {
|
} else if (which[i] == ArgInfo::VARIABLE) {
|
||||||
int ivariable = input->variable->find(ids[i]);
|
int ivariable = input->variable->find(ids[i]);
|
||||||
if (ivariable < 0)
|
if (ivariable < 0) error->all(FLERR, "Variable name for compute reduce does not exist");
|
||||||
error->all(FLERR,"Variable name for compute reduce does not exist");
|
|
||||||
if (input->variable->atomstyle(ivariable) == 0)
|
if (input->variable->atomstyle(ivariable) == 0)
|
||||||
error->all(FLERR, "Compute reduce variable is not atom-style variable");
|
error->all(FLERR, "Compute reduce variable is not atom-style variable");
|
||||||
flavor[i] = PERATOM;
|
flavor[i] = PERATOM;
|
||||||
@ -253,15 +253,19 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
if (nvalues == 1) {
|
if (nvalues == 1) {
|
||||||
scalar_flag = 1;
|
scalar_flag = 1;
|
||||||
if (mode == SUM || mode == SUMSQ) extscalar = 1;
|
if (mode == SUM || mode == SUMSQ)
|
||||||
else extscalar = 0;
|
extscalar = 1;
|
||||||
|
else
|
||||||
|
extscalar = 0;
|
||||||
vector = onevec = nullptr;
|
vector = onevec = nullptr;
|
||||||
indices = owner = nullptr;
|
indices = owner = nullptr;
|
||||||
} else {
|
} else {
|
||||||
vector_flag = 1;
|
vector_flag = 1;
|
||||||
size_vector = nvalues;
|
size_vector = nvalues;
|
||||||
if (mode == SUM || mode == SUMSQ) extvector = 1;
|
if (mode == SUM || mode == SUMSQ)
|
||||||
else extvector = 0;
|
extvector = 1;
|
||||||
|
else
|
||||||
|
extvector = 0;
|
||||||
vector = new double[size_vector];
|
vector = new double[size_vector];
|
||||||
onevec = new double[size_vector];
|
onevec = new double[size_vector];
|
||||||
indices = new int[size_vector];
|
indices = new int[size_vector];
|
||||||
@ -302,31 +306,28 @@ void ComputeReduce::init()
|
|||||||
for (int m = 0; m < nvalues; m++) {
|
for (int m = 0; m < nvalues; m++) {
|
||||||
if (which[m] == ArgInfo::COMPUTE) {
|
if (which[m] == ArgInfo::COMPUTE) {
|
||||||
int icompute = modify->find_compute(ids[m]);
|
int icompute = modify->find_compute(ids[m]);
|
||||||
if (icompute < 0)
|
if (icompute < 0) error->all(FLERR, "Compute ID for compute reduce does not exist");
|
||||||
error->all(FLERR,"Compute ID for compute reduce does not exist");
|
|
||||||
value2index[m] = icompute;
|
value2index[m] = icompute;
|
||||||
|
|
||||||
} else if (which[m] == ArgInfo::FIX) {
|
} else if (which[m] == ArgInfo::FIX) {
|
||||||
int ifix = modify->find_fix(ids[m]);
|
int ifix = modify->find_fix(ids[m]);
|
||||||
if (ifix < 0)
|
if (ifix < 0) error->all(FLERR, "Fix ID for compute reduce does not exist");
|
||||||
error->all(FLERR,"Fix ID for compute reduce does not exist");
|
|
||||||
value2index[m] = ifix;
|
value2index[m] = ifix;
|
||||||
|
|
||||||
} else if (which[m] == ArgInfo::VARIABLE) {
|
} else if (which[m] == ArgInfo::VARIABLE) {
|
||||||
int ivariable = input->variable->find(ids[m]);
|
int ivariable = input->variable->find(ids[m]);
|
||||||
if (ivariable < 0)
|
if (ivariable < 0) error->all(FLERR, "Variable name for compute reduce does not exist");
|
||||||
error->all(FLERR,"Variable name for compute reduce does not exist");
|
|
||||||
value2index[m] = ivariable;
|
value2index[m] = ivariable;
|
||||||
|
|
||||||
} else value2index[m] = ArgInfo::UNKNOWN;
|
} else
|
||||||
|
value2index[m] = ArgInfo::UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
|
|
||||||
if (idregion) {
|
if (idregion) {
|
||||||
iregion = domain->find_region(idregion);
|
region = domain->get_region_by_id(idregion);
|
||||||
if (iregion == -1)
|
if (!region) error->all(FLERR, "Region {} for compute reduce/region does not exist", idregion);
|
||||||
error->all(FLERR,"Region ID for compute reduce/region does not exist");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,8 +386,7 @@ void ComputeReduce::compute_vector()
|
|||||||
}
|
}
|
||||||
for (int m = 0; m < nvalues; m++)
|
for (int m = 0; m < nvalues; m++)
|
||||||
if (replace[m] >= 0) {
|
if (replace[m] >= 0) {
|
||||||
if (me == owner[replace[m]])
|
if (me == owner[replace[m]]) vector[m] = compute_one(m, indices[replace[m]]);
|
||||||
vector[m] = compute_one(m,indices[replace[m]]);
|
|
||||||
MPI_Bcast(&vector[m], 1, MPI_DOUBLE, owner[replace[m]], world);
|
MPI_Bcast(&vector[m], 1, MPI_DOUBLE, owner[replace[m]], world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,8 +407,7 @@ void ComputeReduce::compute_vector()
|
|||||||
}
|
}
|
||||||
for (int m = 0; m < nvalues; m++)
|
for (int m = 0; m < nvalues; m++)
|
||||||
if (replace[m] >= 0) {
|
if (replace[m] >= 0) {
|
||||||
if (me == owner[replace[m]])
|
if (me == owner[replace[m]]) vector[m] = compute_one(m, indices[replace[m]]);
|
||||||
vector[m] = compute_one(m,indices[replace[m]]);
|
|
||||||
MPI_Bcast(&vector[m], 1, MPI_DOUBLE, owner[replace[m]], world);
|
MPI_Bcast(&vector[m], 1, MPI_DOUBLE, owner[replace[m]], world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -463,19 +462,22 @@ double ComputeReduce::compute_one(int m, int flag)
|
|||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) combine(one, x[i][aidx], i);
|
if (mask[i] & groupbit) combine(one, x[i][aidx], i);
|
||||||
} else one = x[flag][aidx];
|
} else
|
||||||
|
one = x[flag][aidx];
|
||||||
} else if (which[m] == ArgInfo::V) {
|
} else if (which[m] == ArgInfo::V) {
|
||||||
double **v = atom->v;
|
double **v = atom->v;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) combine(one, v[i][aidx], i);
|
if (mask[i] & groupbit) combine(one, v[i][aidx], i);
|
||||||
} else one = v[flag][aidx];
|
} else
|
||||||
|
one = v[flag][aidx];
|
||||||
} else if (which[m] == ArgInfo::F) {
|
} else if (which[m] == ArgInfo::F) {
|
||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) combine(one, f[i][aidx], i);
|
if (mask[i] & groupbit) combine(one, f[i][aidx], i);
|
||||||
} else one = f[flag][aidx];
|
} else
|
||||||
|
one = f[flag][aidx];
|
||||||
|
|
||||||
// invoke compute if not previously invoked
|
// invoke compute if not previously invoked
|
||||||
|
|
||||||
@ -494,7 +496,8 @@ double ComputeReduce::compute_one(int m, int flag)
|
|||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
if (mask[i] & groupbit) combine(one, comp_vec[i], i);
|
if (mask[i] & groupbit) combine(one, comp_vec[i], i);
|
||||||
} else one = comp_vec[flag];
|
} else
|
||||||
|
one = comp_vec[flag];
|
||||||
} else {
|
} else {
|
||||||
double **carray_atom = compute->array_atom;
|
double **carray_atom = compute->array_atom;
|
||||||
int n = nlocal;
|
int n = nlocal;
|
||||||
@ -502,7 +505,8 @@ double ComputeReduce::compute_one(int m, int flag)
|
|||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
if (mask[i] & groupbit) combine(one, carray_atom[i][aidxm1], i);
|
if (mask[i] & groupbit) combine(one, carray_atom[i][aidxm1], i);
|
||||||
} else one = carray_atom[flag][aidxm1];
|
} else
|
||||||
|
one = carray_atom[flag][aidxm1];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (flavor[m] == LOCAL) {
|
} else if (flavor[m] == LOCAL) {
|
||||||
@ -515,17 +519,17 @@ double ComputeReduce::compute_one(int m, int flag)
|
|||||||
double *comp_vec = compute->vector_local;
|
double *comp_vec = compute->vector_local;
|
||||||
int n = compute->size_local_rows;
|
int n = compute->size_local_rows;
|
||||||
if (flag < 0)
|
if (flag < 0)
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++) combine(one, comp_vec[i], i);
|
||||||
combine(one,comp_vec[i],i);
|
else
|
||||||
else one = comp_vec[flag];
|
one = comp_vec[flag];
|
||||||
} else {
|
} else {
|
||||||
double **carray_local = compute->array_local;
|
double **carray_local = compute->array_local;
|
||||||
int n = compute->size_local_rows;
|
int n = compute->size_local_rows;
|
||||||
int aidxm1 = aidx - 1;
|
int aidxm1 = aidx - 1;
|
||||||
if (flag < 0)
|
if (flag < 0)
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++) combine(one, carray_local[i][aidxm1], i);
|
||||||
combine(one,carray_local[i][aidxm1],i);
|
else
|
||||||
else one = carray_local[flag][aidxm1];
|
one = carray_local[flag][aidxm1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,7 +537,8 @@ double ComputeReduce::compute_one(int m, int flag)
|
|||||||
|
|
||||||
} else if (which[m] == ArgInfo::FIX) {
|
} else if (which[m] == ArgInfo::FIX) {
|
||||||
if (update->ntimestep % modify->fix[vidx]->peratom_freq)
|
if (update->ntimestep % modify->fix[vidx]->peratom_freq)
|
||||||
error->all(FLERR,"Fix used in compute reduce not "
|
error->all(FLERR,
|
||||||
|
"Fix used in compute reduce not "
|
||||||
"computed at compatible time");
|
"computed at compatible time");
|
||||||
Fix *fix = modify->fix[vidx];
|
Fix *fix = modify->fix[vidx];
|
||||||
|
|
||||||
@ -544,14 +549,16 @@ double ComputeReduce::compute_one(int m, int flag)
|
|||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
if (mask[i] & groupbit) combine(one, fix_vector[i], i);
|
if (mask[i] & groupbit) combine(one, fix_vector[i], i);
|
||||||
} else one = fix_vector[flag];
|
} else
|
||||||
|
one = fix_vector[flag];
|
||||||
} else {
|
} else {
|
||||||
double **fix_array = fix->array_atom;
|
double **fix_array = fix->array_atom;
|
||||||
int aidxm1 = aidx - 1;
|
int aidxm1 = aidx - 1;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) combine(one, fix_array[i][aidxm1], i);
|
if (mask[i] & groupbit) combine(one, fix_array[i][aidxm1], i);
|
||||||
} else one = fix_array[flag][aidxm1];
|
} else
|
||||||
|
one = fix_array[flag][aidxm1];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (flavor[m] == LOCAL) {
|
} else if (flavor[m] == LOCAL) {
|
||||||
@ -559,17 +566,17 @@ double ComputeReduce::compute_one(int m, int flag)
|
|||||||
double *fix_vector = fix->vector_local;
|
double *fix_vector = fix->vector_local;
|
||||||
int n = fix->size_local_rows;
|
int n = fix->size_local_rows;
|
||||||
if (flag < 0)
|
if (flag < 0)
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++) combine(one, fix_vector[i], i);
|
||||||
combine(one,fix_vector[i],i);
|
else
|
||||||
else one = fix_vector[flag];
|
one = fix_vector[flag];
|
||||||
} else {
|
} else {
|
||||||
double **fix_array = fix->array_local;
|
double **fix_array = fix->array_local;
|
||||||
int n = fix->size_local_rows;
|
int n = fix->size_local_rows;
|
||||||
int aidxm1 = aidx - 1;
|
int aidxm1 = aidx - 1;
|
||||||
if (flag < 0)
|
if (flag < 0)
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++) combine(one, fix_array[i][aidxm1], i);
|
||||||
combine(one,fix_array[i][aidxm1],i);
|
else
|
||||||
else one = fix_array[flag][aidxm1];
|
one = fix_array[flag][aidxm1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,7 +593,8 @@ double ComputeReduce::compute_one(int m, int flag)
|
|||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) combine(one, varatom[i], i);
|
if (mask[i] & groupbit) combine(one, varatom[i], i);
|
||||||
} else one = varatom[flag];
|
} else
|
||||||
|
one = varatom[flag];
|
||||||
}
|
}
|
||||||
|
|
||||||
return one;
|
return one;
|
||||||
@ -634,8 +642,10 @@ bigint ComputeReduce::count(int m)
|
|||||||
|
|
||||||
void ComputeReduce::combine(double &one, double two, int i)
|
void ComputeReduce::combine(double &one, double two, int i)
|
||||||
{
|
{
|
||||||
if (mode == SUM || mode == AVE) one += two;
|
if (mode == SUM || mode == AVE)
|
||||||
else if (mode == SUMSQ || mode == AVESQ) one += two*two;
|
one += two;
|
||||||
|
else if (mode == SUMSQ || mode == AVESQ)
|
||||||
|
one += two * two;
|
||||||
else if (mode == MINN) {
|
else if (mode == MINN) {
|
||||||
if (two < one) {
|
if (two < one) {
|
||||||
one = two;
|
one = two;
|
||||||
|
|||||||
@ -38,14 +38,14 @@ class ComputeReduce : public Compute {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
int me;
|
int me;
|
||||||
int mode, nvalues, iregion;
|
int mode, nvalues;
|
||||||
int *which, *argindex, *flavor, *value2index;
|
int *which, *argindex, *flavor, *value2index;
|
||||||
char **ids;
|
char **ids;
|
||||||
double *onevec;
|
double *onevec;
|
||||||
int *replace, *indices, *owner;
|
int *replace, *indices, *owner;
|
||||||
int index;
|
int index;
|
||||||
char *idregion;
|
char *idregion;
|
||||||
|
class Region *region;
|
||||||
int maxatom;
|
int maxatom;
|
||||||
double *varatom;
|
double *varatom;
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// clang-format off
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
https://www.lammps.org/, Sandia National Laboratories
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
@ -29,12 +28,14 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define BIG 1.0e20
|
static constexpr double BIG = 1.0e20;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
ComputeReduceRegion::ComputeReduceRegion(LAMMPS *lmp, int narg, char **arg) :
|
ComputeReduceRegion::ComputeReduceRegion(LAMMPS *lmp, int narg, char **arg) :
|
||||||
ComputeReduce(lmp, narg, arg) {}
|
ComputeReduce(lmp, narg, arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
calculate reduced value for one input M and return it
|
calculate reduced value for one input M and return it
|
||||||
@ -47,9 +48,6 @@ ComputeReduceRegion::ComputeReduceRegion(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
double ComputeReduceRegion::compute_one(int m, int flag)
|
double ComputeReduceRegion::compute_one(int m, int flag)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
Region *region = domain->regions[iregion];
|
|
||||||
region->prematch();
|
region->prematch();
|
||||||
|
|
||||||
// invoke the appropriate attribute,compute,fix,variable
|
// invoke the appropriate attribute,compute,fix,variable
|
||||||
@ -78,24 +76,27 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
|||||||
|
|
||||||
if (which[m] == ArgInfo::X) {
|
if (which[m] == ArgInfo::X) {
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
combine(one, x[i][j], i);
|
combine(one, x[i][j], i);
|
||||||
} else one = x[flag][j];
|
} else
|
||||||
|
one = x[flag][j];
|
||||||
} else if (which[m] == ArgInfo::V) {
|
} else if (which[m] == ArgInfo::V) {
|
||||||
double **v = atom->v;
|
double **v = atom->v;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
combine(one, v[i][j], i);
|
combine(one, v[i][j], i);
|
||||||
} else one = v[flag][j];
|
} else
|
||||||
|
one = v[flag][j];
|
||||||
} else if (which[m] == ArgInfo::F) {
|
} else if (which[m] == ArgInfo::F) {
|
||||||
double **f = atom->f;
|
double **f = atom->f;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
combine(one, f[i][j], i);
|
combine(one, f[i][j], i);
|
||||||
} else one = f[flag][j];
|
} else
|
||||||
|
one = f[flag][j];
|
||||||
|
|
||||||
// invoke compute if not previously invoked
|
// invoke compute if not previously invoked
|
||||||
|
|
||||||
@ -111,18 +112,20 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
|||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
double *compute_vector = compute->vector_atom;
|
double *compute_vector = compute->vector_atom;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
combine(one, compute_vector[i], i);
|
combine(one, compute_vector[i], i);
|
||||||
} else one = compute_vector[flag];
|
} else
|
||||||
|
one = compute_vector[flag];
|
||||||
} else {
|
} else {
|
||||||
double **compute_array = compute->array_atom;
|
double **compute_array = compute->array_atom;
|
||||||
int jm1 = j - 1;
|
int jm1 = j - 1;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
combine(one, compute_array[i][jm1], i);
|
combine(one, compute_array[i][jm1], i);
|
||||||
} else one = compute_array[flag][jm1];
|
} else
|
||||||
|
one = compute_array[flag][jm1];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (flavor[m] == LOCAL) {
|
} else if (flavor[m] == LOCAL) {
|
||||||
@ -134,16 +137,16 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
|||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
double *compute_vector = compute->vector_local;
|
double *compute_vector = compute->vector_local;
|
||||||
if (flag < 0)
|
if (flag < 0)
|
||||||
for (i = 0; i < compute->size_local_rows; i++)
|
for (int i = 0; i < compute->size_local_rows; i++) combine(one, compute_vector[i], i);
|
||||||
combine(one,compute_vector[i],i);
|
else
|
||||||
else one = compute_vector[flag];
|
one = compute_vector[flag];
|
||||||
} else {
|
} else {
|
||||||
double **compute_array = compute->array_local;
|
double **compute_array = compute->array_local;
|
||||||
int jm1 = j - 1;
|
int jm1 = j - 1;
|
||||||
if (flag < 0)
|
if (flag < 0)
|
||||||
for (i = 0; i < compute->size_local_rows; i++)
|
for (int i = 0; i < compute->size_local_rows; i++) combine(one, compute_array[i][jm1], i);
|
||||||
combine(one,compute_array[i][jm1],i);
|
else
|
||||||
else one = compute_array[flag][jm1];
|
one = compute_array[flag][jm1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,34 +161,36 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
|||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
double *fix_vector = fix->vector_atom;
|
double *fix_vector = fix->vector_atom;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
combine(one, fix_vector[i], i);
|
combine(one, fix_vector[i], i);
|
||||||
} else one = fix_vector[flag];
|
} else
|
||||||
|
one = fix_vector[flag];
|
||||||
} else {
|
} else {
|
||||||
double **fix_array = fix->array_atom;
|
double **fix_array = fix->array_atom;
|
||||||
int jm1 = j - 1;
|
int jm1 = j - 1;
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
combine(one, fix_array[i][jm1], i);
|
combine(one, fix_array[i][jm1], i);
|
||||||
} else one = fix_array[flag][jm1];
|
} else
|
||||||
|
one = fix_array[flag][jm1];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (flavor[m] == LOCAL) {
|
} else if (flavor[m] == LOCAL) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
double *fix_vector = fix->vector_local;
|
double *fix_vector = fix->vector_local;
|
||||||
if (flag < 0)
|
if (flag < 0)
|
||||||
for (i = 0; i < fix->size_local_rows; i++)
|
for (int i = 0; i < fix->size_local_rows; i++) combine(one, fix_vector[i], i);
|
||||||
combine(one,fix_vector[i],i);
|
else
|
||||||
else one = fix_vector[flag];
|
one = fix_vector[flag];
|
||||||
} else {
|
} else {
|
||||||
double **fix_array = fix->array_local;
|
double **fix_array = fix->array_local;
|
||||||
int jm1 = j - 1;
|
int jm1 = j - 1;
|
||||||
if (flag < 0)
|
if (flag < 0)
|
||||||
for (i = 0; i < fix->size_local_rows; i++)
|
for (int i = 0; i < fix->size_local_rows; i++) combine(one, fix_array[i][jm1], i);
|
||||||
combine(one,fix_array[i][jm1],i);
|
else
|
||||||
else one = fix_array[flag][jm1];
|
one = fix_array[flag][jm1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,10 +205,11 @@ double ComputeReduceRegion::compute_one(int m, int flag)
|
|||||||
|
|
||||||
input->variable->compute_atom(n, igroup, varatom, 1, 0);
|
input->variable->compute_atom(n, igroup, varatom, 1, 0);
|
||||||
if (flag < 0) {
|
if (flag < 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
for (int i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2]))
|
||||||
combine(one, varatom[i], i);
|
combine(one, varatom[i], i);
|
||||||
} else one = varatom[flag];
|
} else
|
||||||
|
one = varatom[flag];
|
||||||
}
|
}
|
||||||
|
|
||||||
return one;
|
return one;
|
||||||
@ -216,11 +222,11 @@ bigint ComputeReduceRegion::count(int m)
|
|||||||
int n = value2index[m];
|
int n = value2index[m];
|
||||||
|
|
||||||
if (which[m] == ArgInfo::X || which[m] == ArgInfo::V || which[m] == ArgInfo::F)
|
if (which[m] == ArgInfo::X || which[m] == ArgInfo::V || which[m] == ArgInfo::F)
|
||||||
return group->count(igroup,iregion);
|
return group->count(igroup, region);
|
||||||
else if (which[m] == ArgInfo::COMPUTE) {
|
else if (which[m] == ArgInfo::COMPUTE) {
|
||||||
Compute *compute = modify->compute[n];
|
Compute *compute = modify->compute[n];
|
||||||
if (flavor[m] == PERATOM) {
|
if (flavor[m] == PERATOM) {
|
||||||
return group->count(igroup,iregion);
|
return group->count(igroup, region);
|
||||||
} else if (flavor[m] == LOCAL) {
|
} else if (flavor[m] == LOCAL) {
|
||||||
bigint ncount = compute->size_local_rows;
|
bigint ncount = compute->size_local_rows;
|
||||||
bigint ncountall;
|
bigint ncountall;
|
||||||
@ -230,7 +236,7 @@ bigint ComputeReduceRegion::count(int m)
|
|||||||
} else if (which[m] == ArgInfo::FIX) {
|
} else if (which[m] == ArgInfo::FIX) {
|
||||||
Fix *fix = modify->fix[n];
|
Fix *fix = modify->fix[n];
|
||||||
if (flavor[m] == PERATOM) {
|
if (flavor[m] == PERATOM) {
|
||||||
return group->count(igroup,iregion);
|
return group->count(igroup, region);
|
||||||
} else if (flavor[m] == LOCAL) {
|
} else if (flavor[m] == LOCAL) {
|
||||||
bigint ncount = fix->size_local_rows;
|
bigint ncount = fix->size_local_rows;
|
||||||
bigint ncountall;
|
bigint ncountall;
|
||||||
@ -238,7 +244,7 @@ bigint ComputeReduceRegion::count(int m)
|
|||||||
return ncountall;
|
return ncountall;
|
||||||
}
|
}
|
||||||
} else if (which[m] == ArgInfo::VARIABLE)
|
} else if (which[m] == ArgInfo::VARIABLE)
|
||||||
return group->count(igroup,iregion);
|
return group->count(igroup, region);
|
||||||
|
|
||||||
bigint dummy = 0;
|
bigint dummy = 0;
|
||||||
return dummy;
|
return dummy;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user