Merge pull request #3219 from akohlmey/region-lookup-refactor

Region lookup refactor
This commit is contained in:
Axel Kohlmeyer
2022-04-23 11:33:01 -04:00
committed by GitHub
230 changed files with 4546 additions and 4656 deletions

View File

@ -3,7 +3,6 @@ Bonded particle models
The BPM package implements bonded particle models which can be used to
simulate mesoscale solids. Solids are constructed as a collection of
particles which each represent a coarse-grained region of space much
larger than the atomistic scale. Particles within a solid region are
then connected by a network of bonds to provide solid elasticity.
@ -47,33 +46,29 @@ this, LAMMPS requires :doc:`newton <newton>` bond off such that all
processors containing an atom know when a bond breaks. Additionally,
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
special_bonds lj 0 1 1 coul 1 1 1
special_bonds lj 0 1 1 coul 1 1 1
These settings accomplish two goals. First, they turn off 1-3 and 1-4
special bond lists, which are not currently supported for BPMs. As
BPMs often have dense bond networks, generating 1-3 and 1-4 special
bond lists is expensive. By setting the lj weight for 1-2 bonds to
zero, this turns off pairwise interactions. Even though there are no
charges in BPM models, setting a nonzero coul weight for 1-2 bonds
ensures all bonded neighbors are still included in the neighbor list
in case bonds break between neighbor list builds.
These settings accomplish two goals. First, they turn off 1-3 and 1-4
special bond lists, which are not currently supported for BPMs. As
BPMs often have dense bond networks, generating 1-3 and 1-4 special
bond lists is expensive. By setting the lj weight for 1-2 bonds to
zero, this turns off pairwise interactions. Even though there are no
charges in BPM models, setting a nonzero coul weight for 1-2 bonds
ensures all bonded neighbors are still included in the neighbor list
in case bonds break between neighbor list builds.
B) Alternatively, one can simply overlay pair interactions such that all
bonded particles also feel pair interactions. This can be
accomplished by using the *overlay/pair* keyword present in all bpm
bond styles and by using the following special bond settings
(B)
.. code-block:: LAMMPS
Alternatively, one can simply overlay pair interactions such that all
bonded particles also feel pair interactions. This can be accomplished
by using the *overlay/pair* keyword present in all bpm bond styles and
by using the following special bond settings
.. code-block:: LAMMPS
special_bonds lj/coul 1 1 1
special_bonds lj/coul 1 1 1
See the :doc:`Howto <Howto_broken_bonds>` page on broken bonds for
more information.

View File

@ -305,7 +305,7 @@ with fix_adapt are
+------------------------------------+-------+-----------------+
| :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 |
+------------------------------------+-------+-----------------+

View File

@ -36,7 +36,7 @@ are (full) periodic boundary conditions and no other "manipulations"
of the system (e.g. fixes that modify forces or velocities).
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.
----------

View File

@ -68,7 +68,7 @@ Choose the style of time integrator used for molecular dynamics
simulations performed by LAMMPS.
The *verlet* style is the velocity form of the
Störmer-Verlet time integration algorithm (velocity-Verlet)
Stoermer-Verlet time integration algorithm (velocity-Verlet)
----------

View File

@ -315,6 +315,7 @@ borophene
Botero
Botu
Bouguet
Bourasseau
Bourne
boxcolor
boxhi
@ -342,6 +343,7 @@ Broglie
brownian
brownw
Broyden
Brusselle
Bryantsev
Btarget
btype
@ -674,6 +676,7 @@ Deresiewicz
Derjagin
Derjaguin
Derlet
Desbiens
Deserno
Destree
destructor
@ -787,6 +790,7 @@ Dullweber
dumpfile
Dunbrack
Dunweg
Dupend
Dupont
dUs
dV
@ -1669,6 +1673,7 @@ Kusters
Kutta
Kuznetsov
kx
Lachet
Lackmann
Ladd
lagrangian
@ -3188,6 +3193,7 @@ stochastically
stochasticity
Stockmayer
Stoddard
Stoermer
stoichiometric
stoichiometry
Stokesian
@ -3665,6 +3671,7 @@ Wittmaack
wn
Wolde
workflow
workflows
Workum
Worley
Wriggers

View File

@ -387,7 +387,7 @@ double LammpsInterface::atom_quantity_conversion(FundamentalAtomQuantity quantit
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,
double & boxylo, double & boxyhi,
@ -527,14 +527,15 @@ void LammpsInterface::box_periodicity(int & xperiodic,
zperiodic = lammps_->domain->zperiodic;
}
int LammpsInterface::region_id(const char * regionName) const {
int nregion = this->nregion();
for (int iregion = 0; iregion < nregion; iregion++) {
if (strcmp(regionName, region_name(iregion)) == 0) {
int LammpsInterface::region_id(const char *regionName) const {
auto regions = lammps_->domain->get_region_list();
int iregion = 0;
for (auto reg : regions) {
if (strcmp(regionName, reg->id) == 0) {
return iregion;
}
++iregion;
}
throw ATC_Error("Region has not been defined");
return -1;
}
@ -1322,61 +1323,73 @@ int** LammpsInterface::bond_list() const { return lammps_->neighbor->bondlist;
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
{
return lammps_->domain->regions[iRegion]->style;
auto regions = lammps_->domain->get_region_list();
return regions[iRegion]->style;
}
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
{
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
{
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
{
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
{
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
{
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
{
return lammps_->domain->regions[iRegion]->xscale;
auto regions = lammps_->domain->get_region_list();
return regions[iRegion]->xscale;
}
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
{
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 {
return lammps_->domain->regions[iRegion]->match(x,y,z);
auto regions = lammps_->domain->get_region_list();
return regions[iRegion]->match(x,y,z);
}
// -----------------------------------------------------------------

View File

@ -134,10 +134,10 @@ void DumpAtomADIOS::write()
// Now we know the global size and the local subset size and offset
// of the atoms table
auto nAtomsGlobal = static_cast<size_t>(ntotal);
auto startRow = static_cast<size_t>(atomOffset);
auto nAtomsLocal = static_cast<size_t>(nme);
auto nColumns = static_cast<size_t>(size_one);
auto nAtomsGlobal = static_cast<size_t>(ntotal);
auto startRow = static_cast<size_t>(atomOffset);
auto nAtomsLocal = static_cast<size_t>(nme);
auto nColumns = static_cast<size_t>(size_one);
internal->varAtoms.SetShape({nAtomsGlobal, nColumns});
internal->varAtoms.SetSelection({{startRow, 0}, {nAtomsLocal, nColumns}});
@ -238,7 +238,7 @@ void DumpAtomADIOS::init_style()
columnNames = {"id", "type", "xs", "ys", "zs", "ix", "iy", "iz"};
}
for (int icol = 0; icol < (int)columnNames.size(); ++icol)
for (int icol = 0; icol < (int) columnNames.size(); ++icol)
if (keyword_user[icol].size()) columnNames[icol] = keyword_user[icol];
// setup function ptrs
@ -296,7 +296,7 @@ void DumpAtomADIOS::init_style()
int *boundaryptr = reinterpret_cast<int *>(domain->boundary);
internal->io.DefineAttribute<int>("boundary", boundaryptr, 6);
auto nColumns = static_cast<size_t>(size_one);
auto nColumns = static_cast<size_t>(size_one);
internal->io.DefineAttribute<std::string>("columns", columnNames.data(), nColumns);
internal->io.DefineAttribute<std::string>("columnstr", columns);
internal->io.DefineAttribute<std::string>("boundarystr", boundstr);

View File

@ -146,10 +146,10 @@ void DumpCustomADIOS::write()
// Now we know the global size and the local subset size and offset
// of the atoms table
auto nAtomsGlobal = static_cast<size_t>(ntotal);
auto startRow = static_cast<size_t>(atomOffset);
auto nAtomsLocal = static_cast<size_t>(nme);
auto nColumns = static_cast<size_t>(size_one);
auto nAtomsGlobal = static_cast<size_t>(ntotal);
auto startRow = static_cast<size_t>(atomOffset);
auto nAtomsLocal = static_cast<size_t>(nme);
auto nColumns = static_cast<size_t>(size_one);
internal->varAtoms.SetShape({nAtomsGlobal, nColumns});
internal->varAtoms.SetSelection({{startRow, 0}, {nAtomsLocal, nColumns}});
@ -221,8 +221,10 @@ void DumpCustomADIOS::init_style()
int icol = 0;
for (auto item : utils::split_words(columns_default)) {
if (combined.size()) combined += " ";
if (keyword_user[icol].size()) combined += keyword_user[icol];
else combined += item;
if (keyword_user[icol].size())
combined += keyword_user[icol];
else
combined += item;
++icol;
}
columns = utils::strdup(combined);
@ -249,34 +251,30 @@ void DumpCustomADIOS::init_style()
*/
// find current ptr for each compute,fix,variable
// check that fix frequency is acceptable
int icompute;
for (int i = 0; i < ncompute; i++) {
icompute = modify->find_compute(id_compute[i]);
if (icompute < 0) error->all(FLERR, "Could not find dump custom compute ID");
compute[i] = modify->compute[icompute];
compute[i] = modify->get_compute_by_id(id_compute[i]);
if (!compute[i])
error->all(FLERR, "Could not find dump custom/adios compute ID {}", id_compute[i]);
}
int ifix;
for (int i = 0; i < nfix; i++) {
ifix = modify->find_fix(id_fix[i]);
if (ifix < 0) error->all(FLERR, "Could not find dump custom fix ID");
fix[i] = modify->fix[ifix];
if (nevery % modify->fix[ifix]->peratom_freq)
error->all(FLERR, "Dump custom and fix not computed at compatible times");
fix[i] = modify->get_fix_by_id(id_fix[i]);
if (!fix[i]) error->all(FLERR, "Could not find dump custom/adios fix ID {}", id_fix[i]);
if (nevery % fix[i]->peratom_freq)
error->all(FLERR, "dump custom/adios and fix {} with ID {} not computed at compatible times",
fix[i]->style, id_fix[i]);
}
int ivariable;
for (int i = 0; i < nvariable; 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;
}
// set index and check validity of region
if (iregion >= 0) {
iregion = domain->find_region(idregion);
if (iregion == -1) error->all(FLERR, "Region ID for dump custom does not exist");
}
if (idregion && !domain->get_region_by_id(idregion))
error->all(FLERR, "Region {} for dump custom/adios does not exist", idregion);
/* Define the group of variables for the atom style here since it's a fixed
* set */
@ -316,7 +314,7 @@ void DumpCustomADIOS::init_style()
int *boundaryptr = reinterpret_cast<int *>(domain->boundary);
internal->io.DefineAttribute<int>("boundary", boundaryptr, 6);
auto nColumns = static_cast<size_t>(size_one);
auto nColumns = static_cast<size_t>(size_one);
internal->io.DefineAttribute<std::string>("columns", internal->columnNames.data(), nColumns);
internal->io.DefineAttribute<std::string>("columnstr", columns);
internal->io.DefineAttribute<std::string>("boundarystr", boundstr);

View File

@ -221,7 +221,7 @@ bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic,
uint64_t rem = nAtomsTotal % comm->nprocs;
nAtoms = nAtomsTotal / comm->nprocs;
atomOffset = comm->me * nAtoms;
if (comm->me < (int)rem) {
if (comm->me < (int) rem) {
++nAtoms;
atomOffset += comm->me;
} else {
@ -421,7 +421,7 @@ void ReaderADIOS::read_atoms(int n, int nfield, double **fields)
adios2::Variable<double> varAtoms = internal->io.InquireVariable<double>("atoms");
if ((uint64_t)n != nAtoms)
if ((uint64_t) n != nAtoms)
error->one(FLERR,
"ReaderADIOS::read_atoms() expects 'n={}' equal to the number of "
"atoms (={}) for process {} in ADIOS file {}.",

View File

@ -40,8 +40,8 @@ class ReaderADIOS : public Reader {
int read_time(bigint &) override;
void skip() override;
bigint read_header(double[3][3], int &, int &, int, int, int *, char **, int, int, int &,
int &, int &, int &) override;
bigint read_header(double[3][3], int &, int &, int, int, int *, char **, int, int, int &, int &,
int &, int &) override;
void read_atoms(int, int, double **) override;
void open_file(const std::string &) override;

View File

@ -317,10 +317,10 @@ void PairRESquared::coeff(int narg, char **arg)
void PairRESquared::init_style()
{
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
if (!avec) error->all(FLERR, "Pair resquared requires atom style ellipsoid");
neighbor->add_request(this,NeighConst::REQ_DEFAULT);
neighbor->add_request(this, NeighConst::REQ_DEFAULT);
// per-type shape precalculations
// require that atom shapes are identical within each type

View File

@ -30,7 +30,7 @@ namespace LAMMPS_NS {
class FixBocs : public Fix {
public:
FixBocs(class LAMMPS *, int, char **); // MRD NJD
~FixBocs() override; // MRD NJD
~FixBocs() override; // MRD NJD
int setmask() override;
void init() override;
void setup(int) override;

View File

@ -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;
smooth_flag = 1;

View File

@ -56,7 +56,7 @@ FixBrownianAsphere::FixBrownianAsphere(LAMMPS *lmp, int narg, char **arg) :
void FixBrownianAsphere::init()
{
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
if (!avec) error->all(FLERR, "Compute brownian/asphere requires atom style ellipsoid");
// check that all particles are finite-size ellipsoids

View File

@ -48,9 +48,9 @@ class FixBrownianBase : public Fix {
int noise_flag; // 0/1 for noise off/on
int gaussian_noise_flag; // 0/1 for uniform/gaussian noise
double temp; // temperature
double rot_temp; // temperature
double g1, g2; // prefactors in time stepping
double temp; // temperature
double rot_temp; // temperature
double g1, g2; // prefactors in time stepping
class RanMars *rng;
};

View File

@ -100,7 +100,7 @@ void FixPropelSelf::init()
error->all(FLERR, "Fix propel/self requires atom attribute mu with option dipole");
if (mode == QUAT) {
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
if (!avec) error->all(FLERR, "Fix propel/self requires atom style ellipsoid with option quat");
// check that all particles are finite-size ellipsoids

View File

@ -145,16 +145,16 @@ void BondOxdnaFene::ev_tally_xyz(int i, int j, int nlocal, int newton_bond, doub
------------------------------------------------------------------------- */
void BondOxdnaFene::compute(int eflag, int vflag)
{
int a,b,in,type;
double delf[3],delta[3],deltb[3]; // force, torque increment;;
double delr[3],ebond,fbond;
double rsq,Deltasq,rlogarg;
double r,rr0,rr0sq;
int a, b, in, type;
double delf[3], delta[3], deltb[3]; // force, torque increment;;
double delr[3], ebond, fbond;
double rsq, Deltasq, rlogarg;
double r, rr0, rr0sq;
// vectors COM-backbone site in lab frame
double ra_cs[3],rb_cs[3];
double ra_cs[3], rb_cs[3];
// Cartesian unit vectors in lab frame
double ax[3],ay[3],az[3];
double bx[3],by[3],bz[3];
double ax[3], ay[3], az[3];
double bx[3], by[3], bz[3];
double **x = atom->x;
double **f = atom->f;
@ -170,9 +170,9 @@ void BondOxdnaFene::compute(int eflag, int vflag)
// n(x/y/z)_xtrct = extracted local unit vectors in lab frame from oxdna_excv
int dim;
nx_xtrct = (double **) force->pair->extract("nx",dim);
ny_xtrct = (double **) force->pair->extract("ny",dim);
nz_xtrct = (double **) force->pair->extract("nz",dim);
nx_xtrct = (double **) force->pair->extract("nx", dim);
ny_xtrct = (double **) force->pair->extract("ny", dim);
nz_xtrct = (double **) force->pair->extract("nz", dim);
// loop over FENE bonds

View File

@ -39,8 +39,8 @@ class BondOxdnaFene : public Bond {
double single(int, double, int, int, double &) override;
protected:
double *k, *Delta, *r0; // FENE
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double *k, *Delta, *r0; // FENE
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
void allocate();
void ev_tally_xyz(int, int, int, int, double, double, double, double, double, double, double);

View File

@ -55,7 +55,7 @@ class PairOxdna2Coaxstk : public Pair {
double **a_cxst6, **theta_cxst6_0, **dtheta_cxst6_ast;
double **b_cxst6, **dtheta_cxst6_c;
double **AA_cxst1, **BB_cxst1;
double **nx_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double **nx_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
virtual void allocate();
};

View File

@ -45,7 +45,7 @@ class PairOxdna2Dh : public Pair {
protected:
double **qeff_dh_pf, **kappa_dh;
double **b_dh, **cut_dh_ast, **cutsq_dh_ast, **cut_dh_c, **cutsq_dh_c;
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
virtual void allocate();
};

View File

@ -57,7 +57,7 @@ class PairOxdnaCoaxstk : public Pair {
double **b_cxst6, **dtheta_cxst6_c;
double **a_cxst3p, **cosphi_cxst3p_ast, **b_cxst3p, **cosphi_cxst3p_c;
double **a_cxst4p, **cosphi_cxst4p_ast, **b_cxst4p, **cosphi_cxst4p_c;
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
virtual void allocate();
};

View File

@ -54,7 +54,7 @@ class PairOxdnaExcv : public Pair {
double **lj1_sb, **lj2_sb, **b_sb, **cut_sb_c, **cutsq_sb_c;
double **epsilon_bb, **sigma_bb, **cut_bb_ast, **cutsq_bb_ast;
double **lj1_bb, **lj2_bb, **b_bb, **cut_bb_c, **cutsq_bb_c;
double **nx, **ny, **nz; // per-atom arrays for local unit vectors
double **nx, **ny, **nz; // per-atom arrays for local unit vectors
virtual void allocate();
};

View File

@ -60,7 +60,7 @@ class PairOxdnaHbond : public Pair {
double **b_hb7, **dtheta_hb7_c;
double **a_hb8, **theta_hb8_0, **dtheta_hb8_ast;
double **b_hb8, **dtheta_hb8_c;
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
int seqdepflag;
virtual void allocate();

View File

@ -59,7 +59,7 @@ class PairOxdnaStk : public Pair {
double **b_st6, **dtheta_st6_c;
double **a_st1, **cosphi_st1_ast, **b_st1, **cosphi_st1_c;
double **a_st2, **cosphi_st2_ast, **b_st2, **cosphi_st2_c;
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
int seqdepflag;
virtual void allocate();

View File

@ -59,7 +59,7 @@ class PairOxdnaXstk : public Pair {
double **b_xst7, **dtheta_xst7_c;
double **a_xst8, **theta_xst8_0, **dtheta_xst8_ast;
double **b_xst8, **dtheta_xst8_c;
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
virtual void allocate();
};

View File

@ -60,7 +60,7 @@ class PairOxrna2Stk : public Pair {
double **b_st10, **dtheta_st10_c;
double **a_st1, **cosphi_st1_ast, **b_st1, **cosphi_st1_c;
double **a_st2, **cosphi_st2_ast, **b_st2, **cosphi_st2_c;
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double **nx_xtrct, **ny_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
int seqdepflag;
virtual void allocate();

View File

@ -56,7 +56,7 @@ class PairOxrna2Xstk : public Pair {
double **b_xst7, **dtheta_xst7_c;
double **a_xst8, **theta_xst8_0, **dtheta_xst8_ast;
double **b_xst8, **dtheta_xst8_c;
double **nx_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
double **nx_xtrct, **nz_xtrct; // per-atom arrays for local unit vectors
virtual void allocate();
};

View File

@ -484,7 +484,7 @@ void PairLJClass2::init_style()
int list_style = NeighConst::REQ_DEFAULT;
if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) {
auto respa = dynamic_cast<Respa *>( update->integrate);
auto respa = dynamic_cast<Respa *>(update->integrate);
if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT;
if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL;
}
@ -493,8 +493,8 @@ void PairLJClass2::init_style()
// set rRESPA cutoffs
if (utils::strmatch(update->integrate_style, "^respa") &&
(dynamic_cast<Respa *>( update->integrate))->level_inner >= 0)
cut_respa = (dynamic_cast<Respa *>( update->integrate))->cutoff;
(dynamic_cast<Respa *>(update->integrate))->level_inner >= 0)
cut_respa = (dynamic_cast<Respa *>(update->integrate))->cutoff;
else
cut_respa = nullptr;
}

View File

@ -672,7 +672,7 @@ void PairLJClass2CoulLong::init_style()
int list_style = NeighConst::REQ_DEFAULT;
if (update->whichflag == 1 && utils::strmatch(update->integrate_style, "^respa")) {
auto respa = dynamic_cast<Respa *>( update->integrate);
auto respa = dynamic_cast<Respa *>(update->integrate);
if (respa->level_inner >= 0) list_style = NeighConst::REQ_RESPA_INOUT;
if (respa->level_middle >= 0) list_style = NeighConst::REQ_RESPA_ALL;
}
@ -683,8 +683,8 @@ void PairLJClass2CoulLong::init_style()
// set rRESPA cutoffs
if (utils::strmatch(update->integrate_style, "^respa") &&
(dynamic_cast<Respa *>( update->integrate))->level_inner >= 0)
cut_respa = (dynamic_cast<Respa *>( update->integrate))->cutoff;
(dynamic_cast<Respa *>(update->integrate))->level_inner >= 0)
cut_respa = (dynamic_cast<Respa *>(update->integrate))->cutoff;
else
cut_respa = nullptr;

View File

@ -494,7 +494,7 @@ void PairBrownian::init_style()
else if (strstr(modify->fix[i]->style, "wall") != nullptr) {
if (flagwall) error->all(FLERR, "Cannot use multiple fix wall commands with pair brownian");
flagwall = 1; // Walls exist
wallfix = dynamic_cast<FixWall *>( modify->fix[i]);
wallfix = dynamic_cast<FixWall *>(modify->fix[i]);
if (wallfix->xflag) flagwall = 2; // Moving walls exist
}
}

View File

@ -101,7 +101,8 @@ class colvarproxy_lammps : public colvarproxy {
void log(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;

View File

@ -91,8 +91,10 @@ void DumpCFGGZ::write_header(bigint n)
// so molecules are not split across periodic box boundaries
double scale = 1.0;
if (atom->peri_flag) scale = atom->pdscale;
else if (unwrapflag == 1) scale = UNWRAPEXPAND;
if (atom->peri_flag)
scale = atom->pdscale;
else if (unwrapflag == 1)
scale = UNWRAPEXPAND;
std::string header = fmt::format("Number of particles = {}\n", n);
header += fmt::format("A = {:g} Angstrom (basic length-scale)\n", scale);

View File

@ -26,7 +26,7 @@ namespace LAMMPS_NS {
class PairLJSFDipoleSF : public Pair {
public:
PairLJSFDipoleSF(class LAMMPS *_lmp) : Pair(_lmp) {};
PairLJSFDipoleSF(class LAMMPS *_lmp) : Pair(_lmp){};
~PairLJSFDipoleSF() override;
void compute(int, int) override;
void settings(int, char **) override;

View File

@ -25,7 +25,7 @@ FixStyle(drude/transform/inverse,FixDrudeTransform<true>);
namespace LAMMPS_NS {
template <bool inverse> class FixDrudeTransform: public Fix {
template <bool inverse> class FixDrudeTransform : public Fix {
public:
FixDrudeTransform(class LAMMPS *, int, char **);
~FixDrudeTransform() override;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -16,7 +15,6 @@
Contributing author: Andres Jaramillo-Botero (Caltech)
------------------------------------------------------------------------- */
#include "compute_temp_region_eff.h"
#include "atom.h"
@ -33,16 +31,15 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeTempRegionEff::ComputeTempRegionEff(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
Compute(lmp, narg, arg), region(nullptr), idregion(nullptr)
{
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]);
if (iregion == -1)
error->all(FLERR,"Region ID for compute temp/region/eff does not exist");
region = domain->get_region_by_id(arg[3]);
if (!region) error->all(FLERR, "Region {} for compute temp/region/eff does not exist", arg[3]);
idregion = utils::strdup(arg[3]);
scalar_flag = vector_flag = 1;
@ -61,9 +58,9 @@ ComputeTempRegionEff::ComputeTempRegionEff(LAMMPS *lmp, int narg, char **arg) :
ComputeTempRegionEff::~ComputeTempRegionEff()
{
delete [] idregion;
delete[] idregion;
memory->destroy(vbiasall);
delete [] vector;
delete[] vector;
}
/* ---------------------------------------------------------------------- */
@ -72,9 +69,8 @@ void ComputeTempRegionEff::init()
{
// set index and check validity of region
iregion = domain->find_region(idregion);
if (iregion == -1)
error->all(FLERR,"Region ID for compute temp/region/eff does not exist");
region = domain->get_region_by_id(idregion);
if (!region) error->all(FLERR, "Region {} for compute temp/region/eff does not exist", idregion);
}
/* ---------------------------------------------------------------------- */
@ -90,7 +86,7 @@ void ComputeTempRegionEff::setup()
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)
{
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;
}
@ -116,9 +112,8 @@ double ComputeTempRegionEff::compute_scalar()
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
double mefactor = domain->dimension/4.0;
double mefactor = domain->dimension / 4.0;
Region *region = domain->regions[iregion];
region->prematch();
int count = 0;
@ -127,34 +122,35 @@ double ComputeTempRegionEff::compute_scalar()
if (mass) {
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++;
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) *
mass[type[i]];
if (abs(spin[i])==1) {
t += mefactor*mass[type[i]]*ervel[i]*ervel[i];
t += (v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]) * mass[type[i]];
if (abs(spin[i]) == 1) {
t += mefactor * mass[type[i]] * ervel[i] * ervel[i];
ecount++;
}
}
}
double tarray[2],tarray_all[2];
double tarray[2], tarray_all[2];
// Assume 3/2 k T per nucleus
tarray[0] = count-ecount;
tarray[0] = count - ecount;
tarray[1] = t;
MPI_Allreduce(tarray,tarray_all,2,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(tarray, tarray_all, 2, MPI_DOUBLE, MPI_SUM, world);
dof = domain->dimension * tarray_all[0] - extra_dof;
if (dof < 0.0 && tarray_all[0] > 0.0)
error->all(FLERR,"Temperature compute degrees of freedom < 0");
error->all(FLERR, "Temperature compute degrees of freedom < 0");
int one = 0;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) {
if (abs(spin[i])==1) one++;
if (mask[i] & groupbit && region->match(x[i][0], x[i][1], x[i][2])) {
if (abs(spin[i]) == 1) one++;
}
if (dof > 0.0) scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz);
else scalar = 0.0;
if (dof > 0.0)
scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz);
else
scalar = 0.0;
return scalar;
}
@ -174,33 +170,32 @@ void ComputeTempRegionEff::compute_vector()
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
double mefactor = domain->dimension/4.0;
double mefactor = domain->dimension / 4.0;
Region *region = domain->regions[iregion];
region->prematch();
double massone,t[6];
double massone, t[6];
for (i = 0; i < 6; i++) t[i] = 0.0;
for (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])) {
massone = mass[type[i]];
t[0] += massone * v[i][0]*v[i][0];
t[1] += massone * v[i][1]*v[i][1];
t[2] += massone * v[i][2]*v[i][2];
t[3] += massone * v[i][0]*v[i][1];
t[4] += massone * v[i][0]*v[i][2];
t[5] += massone * v[i][1]*v[i][2];
t[0] += massone * v[i][0] * v[i][0];
t[1] += massone * v[i][1] * v[i][1];
t[2] += massone * v[i][2] * v[i][2];
t[3] += massone * v[i][0] * v[i][1];
t[4] += massone * v[i][0] * v[i][2];
t[5] += massone * v[i][1] * v[i][2];
if (abs(spin[i])==1) {
t[0] += mefactor * massone * ervel[i]*ervel[i];
t[1] += mefactor * massone * ervel[i]*ervel[i];
t[2] += mefactor * massone * ervel[i]*ervel[i];
if (abs(spin[i]) == 1) {
t[0] += mefactor * massone * ervel[i] * ervel[i];
t[1] += mefactor * massone * ervel[i] * ervel[i];
t[2] += mefactor * massone * ervel[i] * ervel[i];
}
}
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(t, vector, 6, MPI_DOUBLE, MPI_SUM, world);
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
}
@ -212,7 +207,7 @@ void ComputeTempRegionEff::compute_vector()
void ComputeTempRegionEff::remove_bias(int i, double *v)
{
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;
else {
vbias[0] = v[0];
@ -236,14 +231,12 @@ void ComputeTempRegionEff::remove_bias_all()
if (atom->nmax > maxbias) {
memory->destroy(vbiasall);
maxbias = atom->nmax;
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++)
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]))
vbiasall[i][0] = vbiasall[i][1] = vbiasall[i][2] = 0.0;
else {
vbiasall[i][0] = v[i][0];
@ -289,6 +282,6 @@ void ComputeTempRegionEff::restore_bias_all()
double ComputeTempRegionEff::memory_usage()
{
double bytes = (double)maxbias * sizeof(double);
double bytes = (double) maxbias * sizeof(double);
return bytes;
}

View File

@ -42,7 +42,7 @@ class ComputeTempRegionEff : public Compute {
double memory_usage() override;
protected:
int iregion;
class Region *region;
char *idregion;
};

View File

@ -30,14 +30,12 @@
using namespace LAMMPS_NS;
using namespace MathConst;
/* ---------------------------------------------------------------------- */
ComputeAveSphereAtom::ComputeAveSphereAtom(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
result(nullptr)
Compute(lmp, narg, arg), 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");
// process optional args
@ -45,12 +43,13 @@ ComputeAveSphereAtom::ComputeAveSphereAtom(LAMMPS *lmp, int narg, char **arg) :
int iarg = 3;
while (iarg < narg) {
if (strcmp(arg[iarg],"cutoff") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal compute ave/sphere/atom command");
cutoff = utils::numeric(FLERR,arg[iarg+1],false,lmp);
if (cutoff <= 0.0) error->all(FLERR,"Illegal compute ave/sphere/atom command");
if (strcmp(arg[iarg], "cutoff") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute ave/sphere/atom command");
cutoff = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
if (cutoff <= 0.0) error->all(FLERR, "Illegal compute ave/sphere/atom command");
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;
@ -74,32 +73,32 @@ ComputeAveSphereAtom::~ComputeAveSphereAtom()
void ComputeAveSphereAtom::init()
{
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");
double skin = neighbor->skin;
if (cutoff != 0.0) {
double cutghost; // as computed by Neighbor and Comm
double cutghost; // as computed by Neighbor and Comm
if (force->pair)
cutghost = MAX(force->pair->cutforce+skin,comm->cutghostuser);
cutghost = MAX(force->pair->cutforce + skin, comm->cutghostuser);
else
cutghost = comm->cutghostuser;
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");
}
int cutflag = 1;
if (force->pair) {
if (cutoff == 0.0) {
cutoff = force->pair->cutforce;
}
if (cutoff <= force->pair->cutforce+skin) cutflag = 0;
if (cutoff == 0.0) { cutoff = force->pair->cutforce; }
if (cutoff <= force->pair->cutforce + skin) cutflag = 0;
}
cutsq = cutoff*cutoff;
sphere_vol = 4.0/3.0*MY_PI*cutsq*cutoff;
cutsq = cutoff * cutoff;
sphere_vol = 4.0 / 3.0 * MY_PI * cutsq * cutoff;
// need an occasional full neighbor list
@ -118,11 +117,11 @@ void ComputeAveSphereAtom::init_list(int /*id*/, NeighList *ptr)
void ComputeAveSphereAtom::compute_peratom()
{
int i,j,ii,jj,inum,jnum;
double xtmp,ytmp,ztmp,delx,dely,delz,rsq;
int *ilist,*jlist,*numneigh,**firstneigh;
int i, j, ii, jj, inum, jnum;
double xtmp, ytmp, ztmp, delx, dely, delz, rsq;
int *ilist, *jlist, *numneigh, **firstneigh;
int count;
double vsum[3],vavg[3],vnet[3];
double vsum[3], vavg[3], vnet[3];
invoked_peratom = update->ntimestep;
@ -131,7 +130,7 @@ void ComputeAveSphereAtom::compute_peratom()
if (atom->nmax > nmax) {
memory->destroy(result);
nmax = atom->nmax;
memory->create(result,nmax,2,"ave/sphere/atom:result");
memory->create(result, nmax, 2, "ave/sphere/atom:result");
array_atom = result;
}
@ -179,7 +178,7 @@ void ComputeAveSphereAtom::compute_peratom()
delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
rsq = delx * delx + dely * dely + delz * delz;
if (rsq < cutsq) {
count++;
vsum[0] += v[j][0];
@ -188,9 +187,9 @@ void ComputeAveSphereAtom::compute_peratom()
}
}
vavg[0] = vsum[0]/count;
vavg[1] = vsum[1]/count;
vavg[2] = vsum[2]/count;
vavg[0] = vsum[0] / count;
vavg[1] = vsum[1] / count;
vavg[2] = vsum[2] / count;
// i atom contribution
@ -198,7 +197,7 @@ void ComputeAveSphereAtom::compute_peratom()
vnet[0] = v[i][0] - vavg[0];
vnet[1] = v[i][1] - vavg[1];
vnet[2] = v[i][2] - vavg[2];
double ke_sum = vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2];
double ke_sum = vnet[0] * vnet[0] + vnet[1] * vnet[1] + vnet[2] * vnet[2];
for (jj = 0; jj < jnum; jj++) {
j = jlist[jj];
@ -207,17 +206,17 @@ void ComputeAveSphereAtom::compute_peratom()
delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
rsq = delx * delx + dely * dely + delz * delz;
if (rsq < cutsq) {
count++;
vnet[0] = v[j][0] - vavg[0];
vnet[1] = v[j][1] - vavg[1];
vnet[2] = v[j][2] - vavg[2];
ke_sum += vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2];
ke_sum += vnet[0] * vnet[0] + vnet[1] * vnet[1] + vnet[2] * vnet[2];
}
}
double density = count/sphere_vol;
double temp = ke_sum/3.0/count;
double density = count / sphere_vol;
double temp = ke_sum / 3.0 / count;
result[i][0] = density;
result[i][1] = temp;
}
@ -226,12 +225,12 @@ void ComputeAveSphereAtom::compute_peratom()
/* ---------------------------------------------------------------------- */
int ComputeAveSphereAtom::pack_forward_comm(int n, int *list, double *buf,
int /*pbc_flag*/, int * /*pbc*/)
int ComputeAveSphereAtom::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/,
int * /*pbc*/)
{
double **v = atom->v;
int i,m=0;
int i, m = 0;
for (i = 0; i < n; ++i) {
buf[m++] = v[list[i]][0];
buf[m++] = v[list[i]][1];
@ -247,7 +246,7 @@ void ComputeAveSphereAtom::unpack_forward_comm(int n, int first, double *buf)
{
double **v = atom->v;
int i,last,m=0;
int i, last, m = 0;
last = first + n;
for (i = first; i < last; ++i) {
v[i][0] = buf[m++];
@ -262,6 +261,6 @@ void ComputeAveSphereAtom::unpack_forward_comm(int n, int first, double *buf)
double ComputeAveSphereAtom::memory_usage()
{
double bytes = (double)2*nmax * sizeof(double);
double bytes = (double) 2 * nmax * sizeof(double);
return bytes;
}

View File

@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
ComputeStyle(ave/sphere/atom,ComputeAveSphereAtom)
// clang-format off
ComputeStyle(ave/sphere/atom,ComputeAveSphereAtom);
// clang-format on
#else
#ifndef LMP_COMPUTE_AVE_SPHERE_ATOM_H
@ -37,13 +37,13 @@ class ComputeAveSphereAtom : public Compute {
protected:
int nmax;
double cutoff,cutsq,sphere_vol;
double cutoff, cutsq, sphere_vol;
class NeighList *list;
double **result;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -354,7 +354,6 @@ void ComputeBornMatrix::compute_vector()
if (angleflag) compute_angles();
if (dihedflag) compute_dihedrals();
// sum Born contributions over all procs
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];
}
/* ----------------------------------------------------------------------
@ -390,10 +388,8 @@ void ComputeBornMatrix::compute_pairs()
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
double *special_coul = force->special_coul;
double *special_lj = force->special_lj;
int newton_pair = force->newton_pair;
// invoke half neighbor list (will copy or build if necessary)
neighbor->build_one(list);
@ -412,7 +408,6 @@ void ComputeBornMatrix::compute_pairs()
int a, b, c, d;
double xi1, xi2, xi3;
double fi1, fi2, fi3;
double xj1, xj2, xj3;
double rij[3];
double pair_pref;
@ -454,7 +449,7 @@ void ComputeBornMatrix::compute_pairs()
pair_pref = dupair = du2pair = 0.0;
pair->born_matrix(i, j, itype, jtype, rsq, factor_coul, factor_lj, dupair, du2pair);
pair_pref = 0.5*du2pair - dupair * rinv;
pair_pref = 0.5 * du2pair - dupair * rinv;
// See albemunu in compute_born_matrix.h for indices order.
@ -476,7 +471,6 @@ void ComputeBornMatrix::compute_pairs()
void ComputeBornMatrix::compute_numdiff()
{
double energy;
int vec_index;
// grow arrays if necessary
@ -498,8 +492,6 @@ void ComputeBornMatrix::compute_numdiff()
// loop over 6 strain directions
// compute stress finite difference in each direction
int flag, allflag;
for (int idir = 0; idir < NDIR_VIRIAL; idir++) {
// forward
@ -528,8 +520,7 @@ void ComputeBornMatrix::compute_numdiff()
// apply derivative factor
double denominator = -0.5 / numdelta;
for (int m = 0; m < nvalues; m++)
values_global[m] *= denominator;
for (int m = 0; m < nvalues; m++) values_global[m] *= denominator;
// recompute virial so all virial and energy contributions are as before
// also needed for virial stress addon contributions to Born matrix
@ -633,11 +624,7 @@ void ComputeBornMatrix::update_virial()
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.
// The complete Cijkl terms are the sum of symmetric terms
@ -678,7 +665,6 @@ void ComputeBornMatrix::virial_addon()
values_global[18] += 0.5 * sigv[3];
values_global[19] += 0.5 * sigv[4];
values_global[20] += 0.5 * sigv[5];
}
/* ----------------------------------------------------------------------
@ -727,13 +713,11 @@ double ComputeBornMatrix::memory_usage()
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;
double dx, dy, dz, rsq;
double **x = atom->x;
double **v = atom->v;
int *type = atom->type;
tagint *tag = atom->tag;
int *num_bond = atom->num_bond;
tagint **bond_atom = atom->bond_atom;
@ -821,13 +805,12 @@ void ComputeBornMatrix::compute_bonds()
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;
double delx1, dely1, delz1, delx2, dely2, delz2;
double rsq1, rsq2, r1, r2, cost;
double r1r2, r1r2inv;
double rsq1inv, rsq2inv, cinv;
double *ptr;
double **x = atom->x;
tagint *tag = atom->tag;
@ -920,18 +903,18 @@ void ComputeBornMatrix::compute_angles()
// Worst case scenario. A 0 cosine has an undefined logarithm.
// We then add a small amount of the third bond to the first one
// so they are not orthogonal anymore and recompute.
del1[0] += SMALL*del2[0];
del1[1] += SMALL*del2[1];
del1[2] += SMALL*del2[2];
del1[0] += SMALL * del2[0];
del1[1] += SMALL * del2[1];
del1[2] += SMALL * del2[2];
r1r2 = del1[0] * del2[0] + del1[1] * del2[1] + del1[2] * del2[2];
r1r2inv = 1/r1r2;
r1r2inv = 1 / r1r2;
// cost = cosine of angle
cost = r1r2/(r1 * r2);
cost = r1r2 / (r1 * r2);
} else {
r1r2inv = 1/r1r2;
cost = r1r2/(r1 * r2);
r1r2inv = 1 / r1r2;
cost = r1r2 / (r1 * r2);
}
if (cost > 1.0) cost = 1.0;
@ -986,12 +969,11 @@ void ComputeBornMatrix::compute_angles()
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;
double vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z, vb2xm, vb2ym, vb2zm;
double ax, ay, az, bx, by, bz, rasq, rbsq, dotab, rgsq, rg, ra2inv, rb2inv, dotabinv, rabinv;
double si, co, phi;
double *ptr;
double vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z;
double ax, ay, az, bx, by, bz, rasq, rbsq, dotab, ra2inv, rb2inv, dotabinv, rabinv;
double co;
double **x = atom->x;
tagint *tag = atom->tag;
@ -1013,28 +995,15 @@ void ComputeBornMatrix::compute_dihedrals()
Dihedral *dihedral = force->dihedral;
double dudih, du2dih;
int al, be, mu, nu, e, f;
double b1sq;
double b2sq;
double b3sq;
double b1b2;
double b1b3;
double b2b3;
double b1[3];
double b2[3];
double b3[3];
double dudih, du2dih, b1sq, b2sq, b3sq, b1b2, b1b3, b2b3;
double b1[3], b2[3], b3[3];
// 1st and 2nd order derivatives of the dot products
double dab[6];
double daa[6];
double dbb[6];
double d2ab;
double d2aa;
double d2bb;
double dab[6], daa[6], dbb[6];
double d2ab, d2aa, d2bb;
double dcos[6];
double d2cos;
double dcos[6], d2cos;
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)
// nd = num_dihedral[atom2];
if (molecular == Atom::MOLECULAR) nd = num_dihedral[atom2];
if (molecular == Atom::MOLECULAR)
nd = num_dihedral[atom2];
else {
if (molindex[atom2] < 0) continue;
imol = molindex[atom2];
@ -1120,26 +1090,23 @@ void ComputeBornMatrix::compute_dihedrals()
rasq = ax * ax + ay * ay + az * az;
rbsq = bx * bx + by * by + bz * bz;
rgsq = vb2x * vb2x + vb2y * vb2y + vb2z * vb2z;
dotab = ax*bx + ay*by + az*bz;
rg = sqrt(rgsq);
dotab = ax * bx + ay * by + az * bz;
ra2inv = rb2inv = rabinv = dotabinv = 0.0;
if (rasq > 0) ra2inv = 1.0 / rasq;
if (rbsq > 0) rb2inv = 1.0 / rbsq;
if (dotab != 0.) dotabinv = 1.0/dotab;
if (dotab != 0.) dotabinv = 1.0 / dotab;
rabinv = sqrt(ra2inv * rb2inv);
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.
// We then add a small amount of the third bond to the first one
// so they are not orthogonal anymore and recompute.
b1[0] += SMALL*b3[0];
b1[1] += SMALL*b3[1];
b1[2] += SMALL*b3[2];
b1[0] += SMALL * b3[0];
b1[1] += SMALL * b3[1];
b1[2] += SMALL * b3[2];
b1sq = b1[0] * b1[0] + b1[1] * b1[1] + b1[2] * b1[2];
b3sq = b3[0] * b3[0] + b3[1] * b3[1] + b3[2] * b3[2];
b1b2 = b1[0] * b2[0] + b1[1] * b2[1] + b1[2] * b2[2];
@ -1153,20 +1120,17 @@ void ComputeBornMatrix::compute_dihedrals()
bz = b2[0] * b3[1] - b2[1] * b3[0];
rasq = ax * ax + ay * ay + az * az;
rbsq = bx * bx + by * by + bz * bz;
dotab = ax*bx + ay*by + az*bz;
dotab = ax * bx + ay * by + az * bz;
ra2inv = rb2inv = rabinv = dotabinv = 0.0;
if (rasq > 0) ra2inv = 1.0 / rasq;
if (rbsq > 0) rb2inv = 1.0 / rbsq;
if (dotab != 0.) dotabinv = 1.0/dotab;
if (dotab != 0.) dotabinv = 1.0 / dotab;
rabinv = sqrt(ra2inv * rb2inv);
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;
phi = atan2(si, co);
al = be = mu = nu = e = f = 0;
// clang-format off
for (m = 0; m<6; m++) {

View File

@ -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*/,
double /*yj*/, double delx, double dely, double delz)
double /*yj*/, double delx, double dely,
double delz)
{
int bin1, bin2, next_bin1, next_bin2;
double la = 0.0, lb = 0.0, l_sum = 0.0;

View File

@ -28,7 +28,7 @@ class DumpYAML : public DumpCustom {
public:
DumpYAML(class LAMMPS *, int, char **);
protected:
protected:
bool thermo;
void init_style() override;

View File

@ -59,8 +59,8 @@ extern "C" {
typedef int bool_t;
#if defined(_WIN32) || defined(__APPLE__) || defined(__FreeBSD__) || \
defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__)
#if defined(_WIN32) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || \
defined(__OpenBSD__) || defined(__NetBSD__)
typedef char *caddr_t;
typedef unsigned int u_int;
#endif

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -39,63 +38,53 @@
using namespace LAMMPS_NS;
using namespace FixConst;
#define MAXLINE 1024
/* ---------------------------------------------------------------------- */
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
global_freq = 1; // SeLoss computed every step
extscalar = 0; // SeLoss compute_scalar is intensive
nevery = 1; // Run fix every step
scalar_flag = 1; // Has compute_scalar
global_freq = 1; // SeLoss computed every step
extscalar = 0; // SeLoss compute_scalar is intensive
nevery = 1; // Run fix every step
// args: 0 = fix ID, 1 = group ID, 2 = "electron/stopping"
// 3 = Ecut, 4 = file path
// optional rest: "region" <region name>
// "minneigh" <min number of neighbors>
if (narg < 5) error->all(FLERR,
"Illegal fix electron/stopping command: too few arguments");
if (narg < 5) error->all(FLERR, "Illegal fix electron/stopping command: too few arguments");
Ecut = utils::numeric(FLERR, arg[3],false,lmp);
if (Ecut <= 0.0) error->all(FLERR,
"Illegal fix electron/stopping command: Ecut <= 0");
Ecut = utils::numeric(FLERR, arg[3], false, lmp);
if (Ecut <= 0.0) error->all(FLERR, "Illegal fix electron/stopping command: Ecut <= 0");
int iarg = 5;
iregion = -1;
minneigh = 1;
bool minneighflag = false;
while (iarg < narg) {
if (strcmp(arg[iarg], "region") == 0) {
if (iregion >= 0) error->all(FLERR,
"Illegal fix electron/stopping command: region given twice");
if (iarg+2 > narg) error->all(FLERR,
"Illegal fix electron/stopping command: region name missing");
iregion = domain->find_region(arg[iarg+1]);
if (iregion < 0) error->all(FLERR,
"Region ID for fix electron/stopping does not exist");
if (region) error->all(FLERR, "Illegal fix electron/stopping command: region given twice");
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix electron/stopping command: region name missing");
region = domain->get_region_by_id(arg[iarg + 1]);
if (!region)
error->all(FLERR, "Region {} for fix electron/stopping does not exist", arg[iarg + 1]);
idregion = utils::strdup(arg[iarg + 1]);
iarg += 2;
}
else if (strcmp(arg[iarg], "minneigh") == 0) {
if (minneighflag) error->all(FLERR,
"Illegal fix electron/stopping command: minneigh given twice");
} else if (strcmp(arg[iarg], "minneigh") == 0) {
if (minneighflag)
error->all(FLERR, "Illegal fix electron/stopping command: minneigh given twice");
minneighflag = true;
if (iarg+2 > narg) error->all(FLERR,
"Illegal fix electron/stopping command: minneigh number missing");
minneigh = utils::inumeric(FLERR, arg[iarg+1],false,lmp);
if (minneigh < 0) error->all(FLERR,
"Illegal fix electron/stopping command: minneigh < 0");
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix electron/stopping command: minneigh number missing");
minneigh = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
if (minneigh < 0) error->all(FLERR, "Illegal fix electron/stopping command: minneigh < 0");
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.
// First proc 0 reads the file, then bcast to others.
const int ncol = atom->ntypes + 1;
@ -105,13 +94,12 @@ FixElectronStopping::FixElectronStopping(LAMMPS *lmp, int narg, char **arg) :
read_table(arg[4]);
}
MPI_Bcast(&maxlines, 1 , MPI_INT, 0, world);
MPI_Bcast(&table_entries, 1 , MPI_INT, 0, world);
MPI_Bcast(&maxlines, 1, MPI_INT, 0, world);
MPI_Bcast(&table_entries, 1, MPI_INT, 0, world);
if (comm->me != 0)
memory->create(elstop_ranges, ncol, maxlines, "electron/stopping:table");
if (comm->me != 0) 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 = 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
neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL);
@ -176,18 +168,17 @@ void FixElectronStopping::post_force(int /*vflag*/)
int itype = type[i];
double massone = (atom->rmass) ? atom->rmass[i] : atom->mass[itype];
double v2 = v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2];
double v2 = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2];
double energy = 0.5 * force->mvv2e * massone * v2;
if (energy < Ecut) continue;
if (energy < elstop_ranges[0][0]) continue;
if (energy > elstop_ranges[0][table_entries - 1]) error->one(FLERR,
"Atom kinetic energy too high for fix electron/stopping");
if (energy > elstop_ranges[0][table_entries - 1])
error->one(FLERR, "Atom kinetic energy too high for fix electron/stopping");
if (iregion >= 0) {
if (region) {
// Only apply in the given region
if (domain->regions[iregion]->match(x[i][0], x[i][1], x[i][2]) != 1)
continue;
if (region->match(x[i][0], x[i][1], x[i][2]) != 1) continue;
}
// Binary search to find correct energy range
@ -196,8 +187,10 @@ void FixElectronStopping::post_force(int /*vflag*/)
while (true) {
int ihalf = idown + (iup - idown) / 2;
if (ihalf == idown) break;
if (elstop_ranges[0][ihalf] < energy) idown = ihalf;
else iup = ihalf;
if (elstop_ranges[0][ihalf] < energy)
idown = ihalf;
else
iup = ihalf;
}
double Se_lo = elstop_ranges[itype][idown];
@ -215,7 +208,7 @@ void FixElectronStopping::post_force(int /*vflag*/)
f[i][1] += v[i][1] * factor;
f[i][2] += v[i][2] * factor;
SeLoss += Se * vabs * dt; // very rough approx
SeLoss += Se * vabs * dt; // very rough approx
}
}
@ -254,19 +247,17 @@ void FixElectronStopping::read_table(const char *file)
ValueTokenizer values(line);
elstop_ranges[0][nlines] = values.next_double();
if (elstop_ranges[0][nlines] <= oldvalue)
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];
for (int i = 1; i < ncol; ++i)
elstop_ranges[i][nlines] = values.next_double();
for (int i = 1; i < ncol; ++i) elstop_ranges[i][nlines] = values.next_double();
++nlines;
}
} catch (std::exception &e) {
error->one(FLERR, "Problem parsing electron stopping data: {}", e.what());
}
if (nlines == 0)
error->one(FLERR, "Did not find any data in electron/stopping table file");
if (nlines == 0) error->one(FLERR, "Did not find any data in electron/stopping table file");
table_entries = nlines;
}
@ -281,8 +272,7 @@ void FixElectronStopping::grow_table()
double **new_array;
memory->create(new_array, ncol, new_maxlines, "electron/stopping:table");
for (int i = 0; i < ncol; i++)
memcpy(new_array[i], elstop_ranges[i], maxlines*sizeof(double));
for (int i = 0; i < ncol; i++) memcpy(new_array[i], elstop_ranges[i], maxlines * sizeof(double));
memory->destroy(elstop_ranges);
elstop_ranges = new_array;

View File

@ -52,8 +52,9 @@ class FixElectronStopping : public Fix {
double **elstop_ranges; // [ 0][i]: energies
// [>0][i]: stopping powers per type
int iregion; // region index if used, else -1
int minneigh; // minimum number of neighbors
char *idregion; // region id
class Region *region; // region pointer if used, else NULL
int minneigh; // minimum number of neighbors
class NeighList *list;
};

View File

@ -41,7 +41,8 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
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");
@ -122,7 +123,7 @@ void FixNumDiff::init()
kspace_compute_flag = 0;
if (utils::strmatch(update->integrate_style, "^respa")) {
ilevel_respa = (dynamic_cast<Respa *>( update->integrate))->nlevels - 1;
ilevel_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels - 1;
if (respa_level >= 0) ilevel_respa = MIN(respa_level, ilevel_respa);
}
}
@ -134,9 +135,9 @@ void FixNumDiff::setup(int vflag)
if (utils::strmatch(update->integrate_style, "^verlet"))
post_force(vflag);
else {
(dynamic_cast<Respa *>( update->integrate))->copy_flevel_f(ilevel_respa);
(dynamic_cast<Respa *>(update->integrate))->copy_flevel_f(ilevel_respa);
post_force_respa(vflag, ilevel_respa, 0);
(dynamic_cast<Respa *>( update->integrate))->copy_f_flevel(ilevel_respa);
(dynamic_cast<Respa *>(update->integrate))->copy_f_flevel(ilevel_respa);
}
}

View File

@ -132,7 +132,7 @@ void FixNumDiffVirial::init()
kspace_compute_flag = 0;
if (utils::strmatch(update->integrate_style, "^respa")) {
ilevel_respa = (dynamic_cast<Respa *>( update->integrate))->nlevels - 1;
ilevel_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels - 1;
if (respa_level >= 0) ilevel_respa = MIN(respa_level, ilevel_respa);
}
}
@ -144,9 +144,9 @@ void FixNumDiffVirial::setup(int vflag)
if (utils::strmatch(update->integrate_style, "^verlet"))
post_force(vflag);
else {
(dynamic_cast<Respa *>( update->integrate))->copy_flevel_f(ilevel_respa);
(dynamic_cast<Respa *>(update->integrate))->copy_flevel_f(ilevel_respa);
post_force_respa(vflag, ilevel_respa, 0);
(dynamic_cast<Respa *>( update->integrate))->copy_f_flevel(ilevel_respa);
(dynamic_cast<Respa *>(update->integrate))->copy_f_flevel(ilevel_respa);
}
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -28,35 +27,36 @@
using namespace LAMMPS_NS;
using namespace FixConst;
enum{NONE=-1,X=0,Y=1,Z=2,XYZMASK=3,MINUS=4,PLUS=0};
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;
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);
if (nevery < 1) error->all(FLERR,"Illegal fix oneway command");
nevery = utils::inumeric(FLERR, arg[3], false, lmp);
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], "y") == 0) direction = Y|PLUS;
if (strcmp(arg[5], "Y") == 0) direction = Y|PLUS;
if (strcmp(arg[5], "z") == 0) direction = Z|PLUS;
if (strcmp(arg[5], "Z") == 0) direction = Z|PLUS;
if (strcmp(arg[5],"-x") == 0) direction = X|MINUS;
if (strcmp(arg[5],"-X") == 0) direction = X|MINUS;
if (strcmp(arg[5],"-y") == 0) direction = Y|MINUS;
if (strcmp(arg[5],"-Y") == 0) direction = Y|MINUS;
if (strcmp(arg[5],"-z") == 0) direction = Z|MINUS;
if (strcmp(arg[5],"-Z") == 0) direction = Z|MINUS;
if (strcmp(arg[5], "x") == 0) direction = X | PLUS;
if (strcmp(arg[5], "X") == 0) direction = X | PLUS;
if (strcmp(arg[5], "y") == 0) direction = Y | PLUS;
if (strcmp(arg[5], "Y") == 0) direction = Y | PLUS;
if (strcmp(arg[5], "z") == 0) direction = Z | PLUS;
if (strcmp(arg[5], "Z") == 0) direction = Z | PLUS;
if (strcmp(arg[5], "-x") == 0) direction = X | MINUS;
if (strcmp(arg[5], "-X") == 0) direction = X | MINUS;
if (strcmp(arg[5], "-y") == 0) direction = Y | MINUS;
if (strcmp(arg[5], "-Y") == 0) direction = Y | MINUS;
if (strcmp(arg[5], "-z") == 0) direction = Z | MINUS;
if (strcmp(arg[5], "-Z") == 0) direction = Z | MINUS;
global_freq = nevery;
}
@ -65,7 +65,7 @@ FixOneWay::FixOneWay(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
FixOneWay::~FixOneWay()
{
delete[] regionstr;
delete[] idregion;
}
/* ---------------------------------------------------------------------- */
@ -79,26 +79,24 @@ int FixOneWay::setmask()
void FixOneWay::init()
{
regionidx = domain->find_region(regionstr);
if (regionidx < 0)
error->all(FLERR,"Region for fix oneway does not exist");
region = domain->get_region_by_id(idregion);
if (!region) error->all(FLERR, "Region {} for fix oneway does not exist", idregion);
}
/* ---------------------------------------------------------------------- */
void FixOneWay::end_of_step()
{
Region *region = domain->regions[regionidx];
region->prematch();
const int idx = direction & XYZMASK;
const double * const * const x = atom->x;
double * const * const v = atom->v;
const double *const *const x = atom->x;
double *const *const v = atom->v;
const int *mask = atom->mask;
const int nlocal = atom->nlocal;
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])) {
if (direction & MINUS) {
if (v[i][idx] > 0.0) v[i][idx] = -v[i][idx];
} else {
@ -107,4 +105,3 @@ void FixOneWay::end_of_step()
}
}
}

View File

@ -34,8 +34,8 @@ class FixOneWay : public Fix {
protected:
int direction;
int regionidx;
char *regionstr;
class Region *region;
char *idregion;
};
} // namespace LAMMPS_NS

View File

@ -297,7 +297,7 @@ void FixTTMGrid::read_electron_temperatures(const std::string &filename)
try {
ValueTokenizer values(utils::trim_comment(line));
if (values.count() == 0) {
; // ignore comment only lines
; // ignore comment only lines
} else if (values.count() == 4) {
++nread;
@ -306,18 +306,18 @@ void FixTTMGrid::read_electron_temperatures(const std::string &filename)
int iz = values.next_int();
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
&& iz >= nzlo_in && iz <= nzhi_in) {
if (ix >= nxlo_in && ix <= nxhi_in && iy >= nylo_in && iy <= nyhi_in && iz >= nzlo_in &&
iz <= nzhi_in) {
T_electron[iz][iy][ix] = values.next_double();
T_initial_set[iz][iy][ix] = 1;
}
} else {
throw TokenizerException("Incorrect format in fix ttm electron grid file","");
throw TokenizerException("Incorrect format in fix ttm electron grid file", "");
}
} catch (std::exception &e) {
error->one(FLERR,e.what());
error->one(FLERR, e.what());
}
}
}
@ -356,9 +356,11 @@ void FixTTMGrid::write_electron_temperatures(const std::string &filename)
FPout = fopen(filename.c_str(), "w");
if (!FPout) error->one(FLERR, "Fix ttm/grid could not open output file");
fmt::print(FPout,"# DATE: {} UNITS: {} COMMENT: Electron temperature "
"{}x{}x{} grid at step {}. Created by fix {}\n", utils::current_date(),
update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep, style);
fmt::print(FPout,
"# DATE: {} UNITS: {} COMMENT: Electron temperature "
"{}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);

View File

@ -48,16 +48,16 @@ class FixTTMGrid : public FixTTM {
double memory_usage() override;
private:
int ngridmine,ngridout;
int nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in;
int nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out;
double delxinv,delyinv,delzinv;
int ngridmine, ngridout;
int nxlo_in, nxhi_in, nylo_in, nyhi_in, nzlo_in, nzhi_in;
int nxlo_out, nxhi_out, nylo_out, nyhi_out, nzlo_out, nzhi_out;
double delxinv, delyinv, delzinv;
double skin_original;
FILE *FPout;
class GridComm *gc;
int ngc_buf1,ngc_buf2;
double *gc_buf1,*gc_buf2;
int ngc_buf1, ngc_buf2;
double *gc_buf1, *gc_buf2;
void allocate_grid() override;
void deallocate_grid() override;

View File

@ -114,7 +114,7 @@ void FixViscousSphere::init()
int max_respa = 0;
if (utils::strmatch(update->integrate_style, "^respa")) {
ilevel_respa = max_respa = (dynamic_cast<Respa *>( update->integrate))->nlevels - 1;
ilevel_respa = max_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels - 1;
if (respa_level >= 0) ilevel_respa = MIN(respa_level, max_respa);
}
@ -135,9 +135,9 @@ void FixViscousSphere::setup(int vflag)
if (utils::strmatch(update->integrate_style, "^verlet"))
post_force(vflag);
else {
(dynamic_cast<Respa *>( update->integrate))->copy_flevel_f(ilevel_respa);
(dynamic_cast<Respa *>(update->integrate))->copy_flevel_f(ilevel_respa);
post_force_respa(vflag, ilevel_respa, 0);
(dynamic_cast<Respa *>( update->integrate))->copy_f_flevel(ilevel_respa);
(dynamic_cast<Respa *>(update->integrate))->copy_f_flevel(ilevel_respa);
}
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -23,6 +22,7 @@
#include "domain.h"
#include "error.h"
#include "math_extra.h"
#include "math_special.h"
#include "region.h"
#include "respa.h"
#include "update.h"
@ -31,13 +31,14 @@
using namespace LAMMPS_NS;
using namespace FixConst;
using MathSpecial::powint;
/* ---------------------------------------------------------------------- */
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");
scalar_flag = 1;
vector_flag = 1;
@ -49,15 +50,14 @@ FixWallRegionEES::FixWallRegionEES(LAMMPS *lmp, int narg, char **arg) :
// parse args
iregion = domain->find_region(arg[3]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix wall/region/ees does not exist");
region = domain->get_region_by_id(arg[3]);
if (!region) error->all(FLERR, "Region {} for fix wall/region/ees does not exist", arg[3]);
idregion = utils::strdup(arg[3]);
epsilon = utils::numeric(FLERR,arg[4],false,lmp);
sigma = utils::numeric(FLERR,arg[5],false,lmp);
cutoff = utils::numeric(FLERR,arg[6],false,lmp);
epsilon = utils::numeric(FLERR, arg[4], false, lmp);
sigma = utils::numeric(FLERR, arg[5], false, lmp);
cutoff = utils::numeric(FLERR, arg[6], false, lmp);
if (cutoff <= 0.0) error->all(FLERR,"Fix wall/region/ees cutoff <= 0.0");
if (cutoff <= 0.0) error->all(FLERR, "Fix wall/region/ees cutoff <= 0.0");
eflag = 0;
ewall[0] = ewall[1] = ewall[2] = ewall[3] = 0.0;
@ -67,7 +67,7 @@ FixWallRegionEES::FixWallRegionEES(LAMMPS *lmp, int narg, char **arg) :
FixWallRegionEES::~FixWallRegionEES()
{
delete [] idregion;
delete[] idregion;
}
/* ---------------------------------------------------------------------- */
@ -87,13 +87,11 @@ void FixWallRegionEES::init()
{
// set index and check validity of region
iregion = domain->find_region(idregion);
if (iregion == -1)
error->all(FLERR,"Region ID for fix wall/region/ees does not exist");
region = domain->get_region_by_id(idregion);
if (!region) error->all(FLERR, "Region {} for fix wall/region/ees does not exist", idregion);
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
if (!avec)
error->all(FLERR,"Fix wall/region/ees requires atom style ellipsoid");
avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
if (!avec) error->all(FLERR, "Fix wall/region/ees requires atom style ellipsoid");
// check that all particles are finite-size ellipsoids
// no point particles allowed, spherical is OK
@ -105,33 +103,33 @@ void FixWallRegionEES::init()
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit)
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
coeff1 = ( 2. / 4725. ) * epsilon * pow(sigma,12.0);
coeff2 = ( 1. / 24. ) * epsilon * pow(sigma,6.0);
coeff3 = ( 2. / 315. ) * epsilon * pow(sigma,12.0);
coeff4 = ( 1. / 3. ) * epsilon * pow(sigma,6.0);
coeff5 = ( 4. / 315. ) * epsilon * pow(sigma,12.0);
coeff6 = ( 1. / 12. ) * epsilon * pow(sigma,6.0);
coeff1 = (2.0 / 4725.0) * epsilon * powint(sigma, 12);
coeff2 = (1.0 / 24.0) * epsilon * powint(sigma, 6);
coeff3 = (2.0 / 315.0) * epsilon * powint(sigma, 12);
coeff4 = (1.0 / 3.0) * epsilon * powint(sigma, 6);
coeff5 = (4.0 / 315.0) * epsilon * powint(sigma, 12);
coeff6 = (1.0 / 12.0) * epsilon * powint(sigma, 6);
offset = 0;
if (utils::strmatch(update->integrate_style,"^respa"))
nlevels_respa = (dynamic_cast<Respa *>( update->integrate))->nlevels;
if (utils::strmatch(update->integrate_style, "^respa"))
nlevels_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels;
}
/* ---------------------------------------------------------------------- */
void FixWallRegionEES::setup(int vflag)
{
if (utils::strmatch(update->integrate_style,"^verlet"))
if (utils::strmatch(update->integrate_style, "^respa")) {
auto respa = dynamic_cast<Respa *>(update->integrate);
respa->copy_flevel_f(nlevels_respa - 1);
post_force_respa(vflag, nlevels_respa - 1, 0);
respa->copy_f_flevel(nlevels_respa - 1);
} else {
post_force(vflag);
else {
(dynamic_cast<Respa *>( update->integrate))->copy_flevel_f(nlevels_respa-1);
post_force_respa(vflag,nlevels_respa-1,0);
(dynamic_cast<Respa *>( update->integrate))->copy_f_flevel(nlevels_respa-1);
}
}
@ -139,7 +137,7 @@ void FixWallRegionEES::setup(int vflag)
void FixWallRegionEES::min_setup(int vflag)
{
post_force(vflag);
post_force(vflag);
}
/* ---------------------------------------------------------------------- */
@ -149,8 +147,8 @@ void FixWallRegionEES::post_force(int /*vflag*/)
//sth is needed here, but I dont know what
//that is calculation of sn
int i,m,n;
double rinv,fx,fy,fz,sn,tooclose[3];
int i, m, n;
double rinv, fx, fy, fz, sn, tooclose[3];
eflag = 0;
ewall[0] = ewall[1] = ewall[2] = ewall[3] = 0.0;
@ -165,7 +163,6 @@ void FixWallRegionEES::post_force(int /*vflag*/)
int *mask = atom->mask;
int nlocal = atom->nlocal;
Region *region = domain->regions[iregion];
region->prematch();
int onflag = 0;
@ -176,33 +173,34 @@ void FixWallRegionEES::post_force(int /*vflag*/)
for (i = 0; i < nlocal; i++)
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])) {
onflag = 1;
continue;
}
double A[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
double tempvec[3]= {0,0,0};
double A[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
double tempvec[3] = {0, 0, 0};
double sn2 = 0.0;
double nhat[3] = {0,0,0};
double* shape = bonus[ellipsoid[i]].shape;;
MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat,A);
double nhat[3] = {0, 0, 0};
double *shape = bonus[ellipsoid[i]].shape;
;
MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat, A);
for (int which = 0 ; which < 3; which ++) {//me
nhat[which]=1;
nhat[(which+1)%3] = 0 ;
nhat[(which+2)%3] = 0 ;
sn2 = 0 ;
MathExtra::transpose_matvec(A,nhat,tempvec);
for (int k = 0; k<3; k++) {
for (int which = 0; which < 3; which++) { //me
nhat[which] = 1;
nhat[(which + 1) % 3] = 0;
nhat[(which + 2) % 3] = 0;
sn2 = 0;
MathExtra::transpose_matvec(A, nhat, tempvec);
for (int k = 0; k < 3; k++) {
tempvec[k] *= shape[k];
sn2 += tempvec[k]*tempvec[k];
sn2 += tempvec[k] * tempvec[k];
}
sn = sqrt(sn2);
tooclose[which] = sn;
}
n = region->surface(x[i][0],x[i][1],x[i][2],cutoff);
n = region->surface(x[i][0], x[i][1], x[i][2], cutoff);
for (m = 0; m < n; m++) {
@ -212,12 +210,13 @@ void FixWallRegionEES::post_force(int /*vflag*/)
} else if (region->contact[m].dely != 0 && region->contact[m].r <= tooclose[1]) {
onflag = 1;
continue;
} 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;
continue;
} else rinv = 1.0/region->contact[m].r;
} else
rinv = 1.0 / region->contact[m].r;
ees(m,i);
ees(m, i);
ewall[0] += eng;
fx = fwall * region->contact[m].delx * rinv;
@ -237,15 +236,15 @@ void FixWallRegionEES::post_force(int /*vflag*/)
}
}
if (onflag) error->one(FLERR,"Particle on or inside surface of region "
"used in fix wall/region/ees");
if (onflag)
error->one(FLERR, "Particle on or inside surface of region used in fix wall/region/ees");
}
/* ---------------------------------------------------------------------- */
void FixWallRegionEES::post_force_respa(int vflag, int ilevel, int /*iloop*/)
{
if (ilevel == nlevels_respa-1) post_force(vflag);
if (ilevel == nlevels_respa - 1) post_force(vflag);
}
/* ---------------------------------------------------------------------- */
@ -264,7 +263,7 @@ double FixWallRegionEES::compute_scalar()
// only sum across procs one time
if (eflag == 0) {
MPI_Allreduce(ewall,ewall_all,4,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(ewall, ewall_all, 4, MPI_DOUBLE, MPI_SUM, world);
eflag = 1;
}
return ewall_all[0];
@ -279,10 +278,10 @@ double FixWallRegionEES::compute_vector(int n)
// only sum across procs one time
if (eflag == 0) {
MPI_Allreduce(ewall,ewall_all,4,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(ewall, ewall_all, 4, MPI_DOUBLE, MPI_SUM, world);
eflag = 1;
}
return ewall_all[n+1];
return ewall_all[n + 1];
}
/* ----------------------------------------------------------------------
@ -292,24 +291,23 @@ double FixWallRegionEES::compute_vector(int n)
void FixWallRegionEES::ees(int m, int i)
{
Region *region = domain->regions[iregion];
region->prematch();
double delta, delta2, delta3, delta4, delta5, delta6;
double sigman, sigman2 , sigman3, sigman4, sigman5, sigman6;
double hhss, hhss2, hhss4, hhss7, hhss8; //h^2 - s_n^2
double hps; //h+s_n
double hms; //h-s_n
double sigman, sigman2, sigman3, sigman4, sigman5, sigman6;
double hhss, hhss2, hhss4, hhss7, hhss8; //h^2 - s_n^2
double hps; //h+s_n
double hms; //h-s_n
double twall;
double A[3][3], nhat[3], SAn[3], that[3];
double tempvec[3]= {0,0,0};
double tempvec2[3]= {0,0,0};
double tempvec[3] = {0, 0, 0};
double tempvec2[3] = {0, 0, 0};
double Lx[3][3] = {{0,0,0},{0,0,-1},{0,1,0}};
double Ly[3][3] = {{0,0,1},{0,0,0},{-1,0,0}};
double Lz[3][3] = {{0,-1,0},{1,0,0},{0,0,0}};
double Lx[3][3] = {{0, 0, 0}, {0, 0, -1}, {0, 1, 0}};
double Ly[3][3] = {{0, 0, 1}, {0, 0, 0}, {-1, 0, 0}};
double Lz[3][3] = {{0, -1, 0}, {1, 0, 0}, {0, 0, 0}};
nhat[0] = region->contact[m].delx / region->contact[m].r;
nhat[1] = region->contact[m].dely / region->contact[m].r;
@ -318,14 +316,15 @@ void FixWallRegionEES::ees(int m, int i)
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
double* shape = bonus[ellipsoid[i]].shape;;
MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat,A);
double *shape = bonus[ellipsoid[i]].shape;
;
MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat, A);
sigman2 = 0.0;
MathExtra::transpose_matvec(A,nhat,tempvec);
for (int k = 0; k<3; k++) {
MathExtra::transpose_matvec(A, nhat, tempvec);
for (int k = 0; k < 3; k++) {
tempvec[k] *= shape[k];
sigman2 += tempvec[k]*tempvec[k];
sigman2 += tempvec[k] * tempvec[k];
SAn[k] = tempvec[k];
}
@ -337,14 +336,14 @@ void FixWallRegionEES::ees(int m, int i)
sigman5 = sigman4 * sigman;
sigman6 = sigman3 * sigman3;
delta2 = delta * delta;
delta2 = delta * delta;
delta3 = delta2 * delta;
delta4 = delta2 * delta2;
delta5 = delta3 * delta2;
delta6 = delta3 * delta3;
hhss = delta2 - sigman2;
hhss2 = hhss * hhss;
hhss2 = hhss * hhss;
hhss4 = hhss2 * hhss2;
hhss8 = hhss4 * hhss4;
hhss7 = hhss4 * hhss2 * hhss;
@ -352,31 +351,31 @@ void FixWallRegionEES::ees(int m, int i)
hps = delta + sigman;
hms = delta - sigman;
fwall = -1*coeff4/hhss2 + coeff3
* (21*delta6 + 63*delta4*sigman2 + 27*delta2*sigman4 + sigman6) / hhss8;
fwall = -1 * coeff4 / hhss2 +
coeff3 * (21 * delta6 + 63 * delta4 * sigman2 + 27 * delta2 * sigman4 + sigman6) / hhss8;
eng = -1*coeff2 * (4*delta/sigman2/hhss + 2*log(hms/hps)/sigman3) +
coeff1 * (35*delta5 + 70*delta3*sigman2 + 15*delta*sigman4) / hhss7;
eng = -1 * coeff2 * (4 * delta / sigman2 / hhss + 2 * log(hms / hps) / sigman3) +
coeff1 * (35 * delta5 + 70 * delta3 * sigman2 + 15 * delta * sigman4) / hhss7;
twall = coeff6 * (6*delta3/sigman4/hhss2 - 10*delta/sigman2/hhss2
+ 3*log(hms/hps)/sigman5)
+ coeff5 * (21.*delta5 + 30.*delta3*sigman2 + 5.*delta*sigman4) / hhss8;
twall = coeff6 *
(6 * delta3 / sigman4 / hhss2 - 10 * delta / sigman2 / hhss2 +
3 * log(hms / hps) / sigman5) +
coeff5 * (21. * delta5 + 30. * delta3 * sigman2 + 5. * delta * sigman4) / hhss8;
MathExtra::matvec(Lx,nhat,tempvec);
MathExtra::transpose_matvec(A,tempvec,tempvec2);
for (int k = 0; k<3; k++) tempvec2[k] *= shape[k];
that[0] = MathExtra::dot3(SAn,tempvec2);
MathExtra::matvec(Ly,nhat,tempvec);
MathExtra::transpose_matvec(A,tempvec,tempvec2);
for (int k = 0; k<3; k++) tempvec2[k] *= shape[k];
that[1] = MathExtra::dot3(SAn,tempvec2);
MathExtra::matvec(Lz,nhat,tempvec);
MathExtra::transpose_matvec(A,tempvec,tempvec2);
MathExtra::matvec(Lx, nhat, tempvec);
MathExtra::transpose_matvec(A, tempvec, tempvec2);
for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k];
that[2] = MathExtra::dot3(SAn,tempvec2);
that[0] = MathExtra::dot3(SAn, tempvec2);
for (int j = 0; j<3 ; j++)
torque[j] = twall * that[j];
MathExtra::matvec(Ly, nhat, tempvec);
MathExtra::transpose_matvec(A, tempvec, tempvec2);
for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k];
that[1] = MathExtra::dot3(SAn, tempvec2);
MathExtra::matvec(Lz, nhat, tempvec);
MathExtra::transpose_matvec(A, tempvec, tempvec2);
for (int k = 0; k < 3; k++) tempvec2[k] *= shape[k];
that[2] = MathExtra::dot3(SAn, tempvec2);
for (int j = 0; j < 3; j++) torque[j] = twall * that[j];
}

View File

@ -41,12 +41,12 @@ class FixWallRegionEES : public Fix {
private:
class AtomVecEllipsoid *avec;
int iregion;
double epsilon, sigma, cutoff;
int eflag;
double ewall[4], ewall_all[4];
int nlevels_respa;
char *idregion;
class Region *region;
double coeff1, coeff2, coeff3, coeff4, offset;
double coeff5, coeff6;

View File

@ -89,7 +89,7 @@ void BondFENENM::compute(int eflag, int vflag)
fbond = -k[type] / rlogarg;
// force from n-m term
if (rsq < sigma[type]*sigma[type]) {
if (rsq < sigma[type] * sigma[type]) {
r = sqrt(rsq);
fbond += epsilon[type] * (nn[type] * mm[type] / (nn[type] - mm[type])) *
(pow(sigma[type] / r, nn[type]) - pow(sigma[type] / r, mm[type])) / rsq;
@ -99,7 +99,7 @@ void BondFENENM::compute(int eflag, int vflag)
if (eflag) {
ebond = -0.5 * k[type] * r0sq * log(rlogarg);
if (rsq < sigma[type]*sigma[type])
if (rsq < sigma[type] * sigma[type])
ebond += (epsilon[type] / (nn[type] - mm[type])) *
(mm[type] * pow(sigma[type] / r, nn[type]) - nn[type] * pow(sigma[type] / r, mm[type]));
}
@ -257,7 +257,7 @@ double BondFENENM::single(int type, double rsq, int /*i*/, int /*j*/, double &ff
double eng = -0.5 * k[type] * r0sq * log(rlogarg);
fforce = -k[type] / rlogarg;
if (rsq < sigma[type]*sigma[type]) {
if (rsq < sigma[type] * sigma[type]) {
r = sqrt(rsq);
fforce += epsilon[type] * (nn[type] * mm[type] / (nn[type] - mm[type])) *
(pow(sigma[type] / r, nn[type]) - pow(sigma[type] / r, mm[type])) / rsq;

View File

@ -34,7 +34,8 @@ using namespace MathConst;
BondGaussian::BondGaussian(LAMMPS *lmp) :
Bond(lmp), nterms(nullptr), bond_temperature(nullptr), alpha(nullptr), width(nullptr),
r0(nullptr)
{}
{
}
/* ---------------------------------------------------------------------- */

View File

@ -345,13 +345,11 @@ void DihedralNHarmonic::born_matrix(int nd, int i1, int i2, int i3, int i4,
double &dudih, double &du2dih) {
int i,type;
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,s,kf;
double c,ax,ay,az,bx,by,bz,rasq,rbsq,ra2inv,rb2inv,rabinv;
int **dihedrallist = neighbor->dihedrallist;
double **x = atom->x;
int ndihedrallist = neighbor->ndihedrallist;
type = dihedrallist[nd][4];
vb1x = x[i1][0] - x[i2][0];

View File

@ -33,7 +33,7 @@ class DihedralNHarmonic : public Dihedral {
void write_restart(FILE *) override;
void read_restart(FILE *) override;
void write_data(FILE *) override;
void born_matrix(int /*dtype*/, int, int, int, int, double&, double&) override;
void born_matrix(int /*dtype*/, int, int, int, int, double &, double &) override;
protected:
int *nterms;

View File

@ -99,7 +99,7 @@ void PairE3B::compute(int eflag, int vflag)
ev_init(eflag, vflag);
//clear sumExp array
memset(sumExp, 0, sizeof(double)*maxID);
memset(sumExp, 0, sizeof(double) * maxID);
evdwl = 0.0;
pvector[0] = pvector[1] = pvector[2] = pvector[3] = 0.0;

View File

@ -49,8 +49,8 @@ class PairE3B : public Pair {
int pairmax, pairPerAtom; // size of pair list
int **pairO, ***pairH; // pair lists
double ***exps, ****del3, ***fpair3, *sumExp;
int maxID; //size of global sumExp array
int natoms; //to make sure number of atoms is constant
int maxID; //size of global sumExp array
int natoms; //to make sure number of atoms is constant
virtual void allocate();
void allocateE3B();

View File

@ -38,7 +38,8 @@ class PairLJSmoothLinear : public Pair {
void write_restart_settings(FILE *) override;
void read_restart_settings(FILE *) 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:
double cut_global;

View File

@ -213,7 +213,7 @@ void ComputeFEP::init()
if ((strcmp(force->pair_style, "hybrid") == 0 ||
strcmp(force->pair_style, "hybrid/overlay") == 0)) {
auto pair = dynamic_cast<PairHybrid *>( force->pair);
auto pair = dynamic_cast<PairHybrid *>(force->pair);
for (i = pert->ilo; i <= pert->ihi; i++)
for (j = MAX(pert->jlo, i); j <= pert->jhi; j++)
if (!pair->check_ijtype(i, j, pert->pstyle))

View File

@ -30,7 +30,7 @@ namespace LAMMPS_NS {
class ComputeFEPTA : public Compute {
public:
ComputeFEPTA(class LAMMPS *, int, char **); // compute ID groupID fep/ta temp xy/xz/yz scale_factor
ComputeFEPTA(class LAMMPS *, int, char **);
~ComputeFEPTA() override;
void init() override;
void compute_vector() override;

View File

@ -78,10 +78,12 @@ inline void check_flag(int error_flag, LAMMPS_NS::Error *error, MPI_Comm &world)
else if (all_success == -13)
error->all(FLERR, "Invalid device configuration.");
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.");
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.");
else
error->all(FLERR, "Unknown error in GPU library");

View File

@ -145,7 +145,7 @@ void PairGayBerneGPU::compute(int eflag, int vflag)
void PairGayBerneGPU::init_style()
{
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
if (!avec) error->all(FLERR, "Pair gayberne/gpu requires atom style ellipsoid");
if (!atom->ellipsoid_flag) error->all(FLERR, "Pair gayberne/gpu requires atom style ellipsoid");

View File

@ -59,7 +59,7 @@ enum { SPHERE_SPHERE, SPHERE_ELLIPSE, ELLIPSE_SPHERE, ELLIPSE_ELLIPSE };
PairRESquaredGPU::PairRESquaredGPU(LAMMPS *lmp) : PairRESquared(lmp), gpu_mode(GPU_FORCE)
{
reinitflag = 0;
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
avec = dynamic_cast<AtomVecEllipsoid *>(atom->style_match("ellipsoid"));
if (!avec) error->all(FLERR, "Pair resquared/gpu requires atom style ellipsoid");
quat_nmax = 0;
quat = nullptr;

View File

@ -115,7 +115,7 @@ void FixDampingCundall::init()
int max_respa = 0;
if (utils::strmatch(update->integrate_style, "^respa")) {
ilevel_respa = max_respa = (dynamic_cast<Respa *>( update->integrate))->nlevels - 1;
ilevel_respa = max_respa = (dynamic_cast<Respa *>(update->integrate))->nlevels - 1;
if (respa_level >= 0) ilevel_respa = MIN(respa_level, max_respa);
}
@ -143,9 +143,9 @@ void FixDampingCundall::setup(int vflag)
if (utils::strmatch(update->integrate_style, "^verlet"))
post_force(vflag);
else {
(dynamic_cast<Respa *>( update->integrate))->copy_flevel_f(ilevel_respa);
(dynamic_cast<Respa *>(update->integrate))->copy_flevel_f(ilevel_respa);
post_force_respa(vflag, ilevel_respa, 0);
(dynamic_cast<Respa *>( update->integrate))->copy_f_flevel(ilevel_respa);
(dynamic_cast<Respa *>(update->integrate))->copy_f_flevel(ilevel_respa);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@ class FixPour : public Fix {
private:
int ninsert, ntype, seed;
int iregion, mode, idnext, dstyle, npoly, rigidflag, shakeflag;
int mode, idnext, dstyle, npoly, rigidflag, shakeflag;
int ignoreflag, ignoreline, ignoretri;
double radius_one, radius_max;
double radius_lo, radius_hi;
@ -52,6 +52,8 @@ class FixPour : public Fix {
double xc, yc, rc;
double grav;
char *idrigid, *idshake;
char *idregion;
class Region *region;
class Molecule **onemols;
int nmol, natom_max;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -35,21 +34,16 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) :
FixWallGran(lmp, narg, arg), region(nullptr), region_style(nullptr),
ncontact(nullptr),
walls(nullptr), history_many(nullptr), c2r(nullptr)
FixWallGran(lmp, narg, arg), region(nullptr), ncontact(nullptr), walls(nullptr),
history_many(nullptr), c2r(nullptr)
{
restart_global = 1;
motion_resetflag = 0;
int iregion = domain->find_region(idregion);
if (iregion == -1)
error->all(FLERR,"Region ID for fix wall/gran/region does not exist");
region = domain->regions[iregion];
region_style = utils::strdup(region->style);
region = domain->get_region_by_id(idregion);
if (!region) error->all(FLERR, "Region {} for fix wall/gran/region does not exist", idregion);
nregion = region->nregion;
tmax = domain->regions[iregion]->tmax;
tmax = region->tmax;
c2r = new int[tmax];
// re-allocate atom-based arrays with nshear
@ -67,8 +61,7 @@ FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) :
if (use_history) {
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
ncontact[i] = 0;
for (int i = 0; i < nlocal; i++) ncontact[i] = 0;
}
}
@ -76,8 +69,8 @@ FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) :
FixWallGranRegion::~FixWallGranRegion()
{
delete [] c2r;
delete [] region_style;
delete[] c2r;
delete[] region_style;
memory->destroy(ncontact);
memory->destroy(walls);
@ -90,25 +83,32 @@ void FixWallGranRegion::init()
{
FixWallGran::init();
int iregion = domain->find_region(idregion);
if (iregion == -1)
error->all(FLERR,"Region ID for fix wall/gran/region does not exist");
region = domain->regions[iregion];
auto newregion = domain->get_region_by_id(idregion);
if (!newregion) error->all(FLERR, "Region {} for fix wall/gran/region does not exist", idregion);
// check if region properties changed between runs
// reset if restart info was inconsistent
if ((strcmp(idregion,region->id) != 0)
|| (strcmp(region_style,region->style) != 0)
|| (nregion != region->nregion)) {
error->warning(FLERR,"Region properties for region {} changed between "
"runs, resetting its motion",idregion);
if (newregion != region) {
region = newregion;
if (comm->me == 0)
error->warning(FLERR,
"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();
}
if (motion_resetflag) {
error->warning(FLERR,"Region properties for region {} are inconsistent "
"with restart file, resetting its motion",idregion);
if (comm->me == 0)
error->warning(FLERR,
"Region properties for region {} are inconsistent with restart file, "
"resetting its motion",
idregion);
region->reset_vel();
}
}
@ -117,8 +117,8 @@ void FixWallGranRegion::init()
void FixWallGranRegion::post_force(int /*vflag*/)
{
int i,m,nc,iwall;
double dx,dy,dz,rsq,meff;
int i, m, nc, iwall;
double dx, dy, dz, rsq, meff;
double vwall[3];
// do not update shear history during setup
@ -133,17 +133,19 @@ void FixWallGranRegion::post_force(int /*vflag*/)
if (neighbor->ago == 0 && fix_rigid) {
int tmp;
int *body = (int *) fix_rigid->extract("body",tmp);
auto mass_body = (double *) fix_rigid->extract("masstotal",tmp);
int *body = (int *) fix_rigid->extract("body", tmp);
auto mass_body = (double *) fix_rigid->extract("masstotal", tmp);
if (atom->nmax > nmax) {
memory->destroy(mass_rigid);
nmax = atom->nmax;
memory->create(mass_rigid,nmax,"wall/gran:mass_rigid");
memory->create(mass_rigid, nmax, "wall/gran:mass_rigid");
}
int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++) {
if (body[i] >= 0) mass_rigid[i] = mass_body[body[i]];
else mass_rigid[i] = 0.0;
if (body[i] >= 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();
}
if (peratom_flag) {
clear_stored_contacts();
}
if (peratom_flag) { clear_stored_contacts(); }
for (i = 0; i < nlocal; i++) {
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) {
nc = region->surface(x[i][0],x[i][1],x[i][2],
radius[i]+pulloff_distance(radius[i]));
nc = region->surface(x[i][0], x[i][1], x[i][2], radius[i] + pulloff_distance(radius[i]));
} else {
nc = region->surface(x[i][0], x[i][1], x[i][2], radius[i]);
}
else{
nc = region->surface(x[i][0],x[i][1],x[i][2],radius[i]);
}
if (nc > tmax)
error->one(FLERR,"Too many wall/gran/region contacts for one particle");
if (nc > tmax) error->one(FLERR, "Too many wall/gran/region contacts for one particle");
// shear history maintenance
// update ncontact,walls,shear2many for particle I
@ -204,11 +201,11 @@ void FixWallGranRegion::post_force(int /*vflag*/)
if (ncontact[i] == 0) {
ncontact[i] = 1;
walls[i][0] = iwall;
for (m = 0; m < size_history; m++)
history_many[i][0][m] = 0.0;
for (m = 0; m < size_history; m++) history_many[i][0][m] = 0.0;
} else if (ncontact[i] > 1 || iwall != walls[i][0])
update_contacts(i,nc);
} else update_contacts(i,nc);
update_contacts(i, nc);
} else
update_contacts(i, nc);
}
// process current contacts
@ -217,12 +214,11 @@ void FixWallGranRegion::post_force(int /*vflag*/)
// rsq = squared contact distance
// xc = contact point
rsq = region->contact[ic].r*region->contact[ic].r;
rsq = region->contact[ic].r * region->contact[ic].r;
if (pairstyle == FixWallGran::GRANULAR && normal_model == FixWallGran::JKR) {
if (history_many[i][c2r[ic]][0] == 0.0 && rsq > radius[i]*radius[i]) {
for (m = 0; m < size_history; m++)
history_many[i][0][m] = 0.0;
if (history_many[i][c2r[ic]][0] == 0.0 && rsq > radius[i] * radius[i]) {
for (m = 0; m < size_history; m++) history_many[i][0][m] = 0.0;
continue;
}
}
@ -256,20 +252,16 @@ void FixWallGranRegion::post_force(int /*vflag*/)
contact = nullptr;
if (pairstyle == FixWallGran::HOOKE)
hooke(rsq,dx,dy,dz,vwall,v[i],f[i],
omega[i],torque[i],radius[i],meff, contact);
hooke(rsq, dx, dy, dz, vwall, v[i], f[i], omega[i], torque[i], radius[i], meff, contact);
else if (pairstyle == FixWallGran::HOOKE_HISTORY)
hooke_history(rsq,dx,dy,dz,vwall,v[i],f[i],
omega[i],torque[i],radius[i],meff,
history_many[i][c2r[ic]], contact);
hooke_history(rsq, dx, dy, dz, vwall, v[i], f[i], omega[i], torque[i], radius[i], meff,
history_many[i][c2r[ic]], contact);
else if (pairstyle == FixWallGran::HERTZ_HISTORY)
hertz_history(rsq,dx,dy,dz,vwall,region->contact[ic].radius,
v[i],f[i],omega[i],torque[i],
radius[i],meff,history_many[i][c2r[ic]], contact);
hertz_history(rsq, dx, dy, dz, vwall, region->contact[ic].radius, v[i], f[i], omega[i],
torque[i], radius[i], meff, history_many[i][c2r[ic]], contact);
else if (pairstyle == FixWallGran::GRANULAR)
granular(rsq,dx,dy,dz,vwall,region->contact[ic].radius,
v[i],f[i],omega[i],torque[i],
radius[i],meff,history_many[i][c2r[ic]],contact);
granular(rsq, dx, dy, dz, vwall, region->contact[ic].radius, v[i], f[i], omega[i],
torque[i], radius[i], meff, history_many[i][c2r[ic]], contact);
}
}
}
@ -285,7 +277,7 @@ void FixWallGranRegion::post_force(int /*vflag*/)
void FixWallGranRegion::update_contacts(int i, int nc)
{
int j,m,iold,nold,ilast,inew,iadd,iwall;
int j, m, iold, nold, ilast, inew, iadd, iwall;
// loop over old contacts
// if not in new contact list:
@ -296,12 +288,12 @@ void FixWallGranRegion::update_contacts(int i, int nc)
for (m = 0; m < nc; m++)
if (region->contact[m].iwall == walls[i][iold]) break;
if (m >= nc) {
ilast = ncontact[i]-1;
for (j = 0; j < size_history; j++)
history_many[i][iold][j] = history_many[i][ilast][j];
ilast = ncontact[i] - 1;
for (j = 0; j < size_history; j++) history_many[i][iold][j] = history_many[i][ilast][j];
walls[i][iold] = walls[i][ilast];
ncontact[i]--;
} else iold++;
} else
iold++;
}
// loop over new contacts
@ -315,13 +307,13 @@ void FixWallGranRegion::update_contacts(int i, int nc)
iwall = region->contact[inew].iwall;
for (m = 0; m < nold; m++)
if (walls[i][m] == iwall) break;
if (m < nold) c2r[m] = inew;
if (m < nold)
c2r[m] = inew;
else {
iadd = ncontact[i];
c2r[iadd] = inew;
for (j = 0; j < size_history; j++)
history_many[i][iadd][j] = 0.0;
for (j = 0; j < size_history; j++) history_many[i][iadd][j] = 0.0;
walls[i][iadd] = iwall;
ncontact[i]++;
}
@ -336,12 +328,12 @@ double FixWallGranRegion::memory_usage()
{
int nmax = atom->nmax;
double bytes = 0.0;
if (use_history) { // shear history
bytes += (double)nmax * sizeof(int); // ncontact
bytes += (double)nmax*tmax * sizeof(int); // walls
bytes += (double)nmax*tmax*size_history * sizeof(double); // history_many
if (use_history) { // shear history
bytes += (double) nmax * sizeof(int); // ncontact
bytes += (double) nmax * tmax * sizeof(int); // walls
bytes += (double) nmax * tmax * size_history * sizeof(double); // history_many
}
if (fix_rigid) bytes += (double)nmax * sizeof(int); // mass_rigid
if (fix_rigid) bytes += (double) nmax * sizeof(int); // mass_rigid
return bytes;
}
@ -352,12 +344,11 @@ double FixWallGranRegion::memory_usage()
void FixWallGranRegion::grow_arrays(int nmax)
{
if (use_history) {
memory->grow(ncontact,nmax,"fix_wall_gran:ncontact");
memory->grow(walls,nmax,tmax,"fix_wall_gran:walls");
memory->grow(history_many,nmax,tmax,size_history,"fix_wall_gran:history_many");
memory->grow(ncontact, nmax, "fix_wall_gran:ncontact");
memory->grow(walls, nmax, tmax, "fix_wall_gran:walls");
memory->grow(history_many, nmax, tmax, size_history, "fix_wall_gran:history_many");
}
if (peratom_flag)
memory->grow(array_atom,nmax,size_peratom_cols,"fix_wall_gran:array_atom");
if (peratom_flag) memory->grow(array_atom, nmax, size_peratom_cols, "fix_wall_gran:array_atom");
}
/* ----------------------------------------------------------------------
@ -366,21 +357,19 @@ void FixWallGranRegion::grow_arrays(int nmax)
void FixWallGranRegion::copy_arrays(int i, int j, int /*delflag*/)
{
int m,n,iwall;
int m, n, iwall;
if (use_history) {
n = ncontact[i];
for (iwall = 0; iwall < n; iwall++) {
walls[j][iwall] = walls[i][iwall];
for (m = 0; m < size_history; m++)
history_many[j][iwall][m] = history_many[i][iwall][m];
for (m = 0; m < size_history; m++) history_many[j][iwall][m] = history_many[i][iwall][m];
}
ncontact[j] = ncontact[i];
}
if (peratom_flag) {
for (int m = 0; m < size_peratom_cols; m++)
array_atom[j][m] = array_atom[i][m];
for (int m = 0; m < size_peratom_cols; 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)
{
if (use_history)
ncontact[i] = 0;
if (use_history) ncontact[i] = 0;
if (peratom_flag) {
for (int m = 0; m < size_peratom_cols; m++)
array_atom[i][m] = 0;
for (int m = 0; m < size_peratom_cols; m++) array_atom[i][m] = 0;
}
}
@ -412,13 +399,11 @@ int FixWallGranRegion::pack_exchange(int i, double *buf)
buf[n++] = ubuf(count).d;
for (int iwall = 0; iwall < count; iwall++) {
buf[n++] = ubuf(walls[i][iwall]).d;
for (m = 0; m < size_history; m++)
buf[n++] = history_many[i][iwall][m];
for (m = 0; m < size_history; m++) buf[n++] = history_many[i][iwall][m];
}
}
if (peratom_flag) {
for (int m = 0; m < size_peratom_cols; m++)
buf[n++] = array_atom[i][m];
for (int m = 0; m < size_peratom_cols; m++) buf[n++] = array_atom[i][m];
}
return n;
@ -432,19 +417,16 @@ int FixWallGranRegion::unpack_exchange(int nlocal, double *buf)
{
int m;
int n = 0;
if (use_history) {
int count = ncontact[nlocal] = (int) ubuf(buf[n++]).i;
for (int iwall = 0; iwall < count; iwall++) {
walls[nlocal][iwall] = (int) ubuf(buf[n++]).i;
for (m = 0; m < size_history; m++)
history_many[nlocal][iwall][m] = buf[n++];
for (m = 0; m < size_history; m++) history_many[nlocal][iwall][m] = buf[n++];
}
}
if (peratom_flag) {
for (int m = 0; m < size_peratom_cols; m++)
array_atom[nlocal][m] = buf[n++];
for (int m = 0; m < size_peratom_cols; m++) array_atom[nlocal][m] = buf[n++];
}
return n;
@ -466,8 +448,7 @@ int FixWallGranRegion::pack_restart(int i, double *buf)
buf[n++] = ubuf(count).d;
for (int iwall = 0; iwall < count; iwall++) {
buf[n++] = ubuf(walls[i][iwall]).d;
for (m = 0; m < size_history; m++)
buf[n++] = history_many[i][iwall][m];
for (m = 0; m < size_history; m++) buf[n++] = history_many[i][iwall][m];
}
// pack buf[0] this way because other fixes unpack it
buf[0] = n;
@ -490,14 +471,13 @@ void FixWallGranRegion::unpack_restart(int nlocal, int nth)
// unpack the Nth first values this way because other fixes pack them
int m = 0;
for (int i = 0; i < nth; i++) m += static_cast<int> (extra[nlocal][m]);
for (int i = 0; i < nth; i++) m += static_cast<int>(extra[nlocal][m]);
m++;
int count = ncontact[nlocal] = (int) ubuf(extra[nlocal][m++]).i;
for (int iwall = 0; iwall < count; iwall++) {
walls[nlocal][iwall] = (int) ubuf(extra[nlocal][m++]).i;
for (k = 0; k < size_history; k++)
history_many[nlocal][iwall][k] = extra[nlocal][m++];
for (k = 0; k < size_history; k++) history_many[nlocal][iwall][k] = extra[nlocal][m++];
}
}
@ -508,7 +488,7 @@ void FixWallGranRegion::unpack_restart(int nlocal, int nth)
int FixWallGranRegion::maxsize_restart()
{
if (!use_history) return 0;
return 2 + tmax*(size_history+1);
return 2 + tmax * (size_history + 1);
}
/* ----------------------------------------------------------------------
@ -518,7 +498,7 @@ int FixWallGranRegion::maxsize_restart()
int FixWallGranRegion::size_restart(int nlocal)
{
if (!use_history) return 0;
return 2 + ncontact[nlocal]*(size_history+1);
return 2 + ncontact[nlocal] * (size_history + 1);
}
/* ----------------------------------------------------------------------
@ -530,7 +510,7 @@ void FixWallGranRegion::write_restart(FILE *fp)
if (comm->me) return;
int len = 0;
region->length_restart_string(len);
fwrite(&len, sizeof(int),1,fp);
fwrite(&len, sizeof(int), 1, fp);
region->write_restart(fp);
}
@ -541,5 +521,5 @@ void FixWallGranRegion::write_restart(FILE *fp)
void FixWallGranRegion::restart(char *buf)
{
int n = 0;
if (!region->restart(buf,n)) motion_resetflag = 1;
if (!region->restart(buf, n)) motion_resetflag = 1;
}

View File

@ -67,8 +67,8 @@ PairGranHookeHistory::PairGranHookeHistory(LAMMPS *lmp) : Pair(lmp)
// this is so final order of Modify:fix will conform to input script
fix_history = nullptr;
fix_dummy = dynamic_cast<FixDummy *>( modify->add_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me) +
" all DUMMY"));
fix_dummy = dynamic_cast<FixDummy *>(
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
if (history) neighbor->add_request(this, NeighConst::REQ_SIZE|NeighConst::REQ_HISTORY);
else neighbor->add_request(this, NeighConst::REQ_SIZE);
if (history)
neighbor->add_request(this, NeighConst::REQ_SIZE | NeighConst::REQ_HISTORY);
else
neighbor->add_request(this, NeighConst::REQ_SIZE);
dt = update->dt;
@ -454,8 +456,8 @@ void PairGranHookeHistory::init_style()
if (history && (fix_history == nullptr)) {
auto cmd = fmt::format("NEIGH_HISTORY_HH{} all NEIGH_HISTORY {}", instance_me, size_history);
fix_history = dynamic_cast<FixNeighHistory *>( modify->replace_fix(
"NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me), cmd, 1));
fix_history = dynamic_cast<FixNeighHistory *>(
modify->replace_fix("NEIGH_HISTORY_HH_DUMMY" + std::to_string(instance_me), cmd, 1));
fix_history->pair = this;
}
@ -476,7 +478,8 @@ void PairGranHookeHistory::init_style()
if (ifix->rigid_flag) {
if (fix_rigid)
error->all(FLERR, "Only one fix rigid command at a time allowed");
else fix_rigid = ifix;
else
fix_rigid = ifix;
}
}
@ -521,8 +524,9 @@ void PairGranHookeHistory::init_style()
// set fix which stores history info
if (history) {
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");
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");
}
}

View File

@ -141,7 +141,8 @@ void PairKolmogorovCrespiFull::settings(int narg, char **arg)
{
if (narg < 1 || narg > 2) error->all(FLERR, "Illegal pair_style command");
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);
if (narg == 2) tap_flag = utils::numeric(FLERR, arg[1], false, lmp);

View File

@ -251,9 +251,10 @@ void KimInit::determine_model_type_and_units(char *model_name, char *user_units,
return;
} else if (unit_conversion_mode) {
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) {
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,
temperatureUnit, timeUnit, model_name, &units_accepted, &pkim);
if (units_accepted) {
@ -316,7 +317,7 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units, KIM
modify->add_fix("KIM_MODEL_STORE all STORE/KIM");
ifix = modify->find_fix("KIM_MODEL_STORE");
auto fix_store = dynamic_cast<FixStoreKIM *>( modify->fix[ifix]);
auto fix_store = dynamic_cast<FixStoreKIM *>(modify->fix[ifix]);
fix_store->setptr("model_name", (void *) model_name);
fix_store->setptr("user_units", (void *) user_units);
fix_store->setptr("model_units", (void *) model_units);

View File

@ -82,7 +82,7 @@ class KimInit : protected Pointers {
void do_init(char *, char *, char *, KIM_Model *&);
void do_variables(const std::string &, const std::string &);
void print_dirs(struct KIM_Collections * const collections) const;
void print_dirs(struct KIM_Collections *const collections) const;
};
} // namespace LAMMPS_NS

View File

@ -87,9 +87,7 @@ void FixSetForceKokkos<DeviceType>::post_force(int /*vflag*/)
// update region if necessary
region = nullptr;
if (iregion >= 0) {
region = domain->regions[iregion];
if (region) {
region->prematch();
DAT::tdual_int_1d k_match = DAT::tdual_int_1d("setforce:k_match",nlocal);
KokkosBase* regionKKBase = dynamic_cast<KokkosBase*>(region);

View File

@ -81,8 +81,6 @@ class FixSetForceKokkos : public FixSetForce {
typename AT::t_x_array_randomread x;
typename AT::t_f_array f;
typename AT::t_int_1d_randomread mask;
class Region* region;
};
}

View File

@ -14,7 +14,7 @@
#ifndef LMP_FFT3D_WRAP_H
#define LMP_FFT3D_WRAP_H
#include "fft3d.h" // IWYU pragma: export
#include "fft3d.h" // IWYU pragma: export
#include "pointers.h"
namespace LAMMPS_NS {

View File

@ -31,8 +31,8 @@ class PPPMDispTIP4P : public PPPMDisp {
void init() override;
protected:
void particle_map_c(double, double, double, double, int **, int, int, int, int, int, int,
int, int) override;
void particle_map_c(double, double, double, double, int **, int, int, int, int, int, int, int,
int) override;
void make_rho_c() override;
void fieldforce_c_ik() override;
void fieldforce_c_ad() override;

View File

@ -2387,8 +2387,8 @@ void FixLbFluid::dump(const bigint step)
" </DataItem>\n"
" </Attribute>\n\n",
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[1], fluid_global_n0[0], dump_file_name_raw.c_str());
fluid_global_n0[0], sizeof(double), offset, fluid_global_n0[2], fluid_global_n0[1],
fluid_global_n0[0], dump_file_name_raw.c_str());
fmt::print(dump_file_handle_xdmf,
" <Attribute Name=\"velocity\" AttributeType=\"Vector\">\n"
" <DataItem ItemType=\"Function\" Function=\"$0 * {:f}\" "

View File

@ -111,7 +111,7 @@ class FixLbFluid : public Fix {
int step;
int n_stencil; // Number of points for spread/interpolate stencil
int n_stencil; // Number of points for spread/interpolate stencil
double bodyforcex, bodyforcey, bodyforcez; // Body Forces acting on the fluid (default=0)
double vwtp, vwbt; // Velocities of the z walls in the y

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
*
* *** Smooth Mach Dynamics ***
@ -41,320 +40,297 @@
using namespace LAMMPS_NS;
using namespace FixConst;
enum {
NONE, CONSTANT, EQUAL, ATOM
};
enum { NONE, CONSTANT, EQUAL, ATOM };
/* ---------------------------------------------------------------------- */
FixSMDSetVel::FixSMDSetVel(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) {
if (narg < 6)
error->all(FLERR, "Illegal fix setvelocity command");
Fix(lmp, narg, arg), xstr(nullptr), ystr(nullptr), zstr(nullptr), idregion(nullptr),
region(nullptr), sforce(nullptr)
{
if (narg < 6) error->all(FLERR, "Illegal fix setvelocity command");
dynamic_group_allow = 1;
vector_flag = 1;
size_vector = 3;
global_freq = 1;
extvector = 1;
dynamic_group_allow = 1;
vector_flag = 1;
size_vector = 3;
global_freq = 1;
extvector = 1;
xstr = ystr = zstr = nullptr;
if (strstr(arg[3], "v_") == arg[3]) {
xstr = utils::strdup(&arg[3][2]);
} else if (strcmp(arg[3], "NULL") == 0) {
xstyle = NONE;
} else {
xvalue = utils::numeric(FLERR, arg[3], false, lmp);
xstyle = CONSTANT;
}
if (strstr(arg[4], "v_") == arg[4]) {
ystr = utils::strdup(&arg[4][2]);
} else if (strcmp(arg[4], "NULL") == 0) {
ystyle = NONE;
} else {
yvalue = utils::numeric(FLERR, arg[4], false, lmp);
ystyle = CONSTANT;
}
if (strstr(arg[5], "v_") == arg[5]) {
zstr = utils::strdup(&arg[5][2]);
} else if (strcmp(arg[5], "NULL") == 0) {
zstyle = NONE;
} else {
zvalue = utils::numeric(FLERR, arg[5], false, lmp);
zstyle = CONSTANT;
}
if (strstr(arg[3], "v_") == arg[3]) {
xstr = utils::strdup( &arg[3][2]);
} else if (strcmp(arg[3], "NULL") == 0) {
xstyle = NONE;
} else {
xvalue = utils::numeric(FLERR, arg[3],false,lmp);
xstyle = CONSTANT;
}
if (strstr(arg[4], "v_") == arg[4]) {
ystr = utils::strdup( &arg[4][2]);
} else if (strcmp(arg[4], "NULL") == 0) {
ystyle = NONE;
} else {
yvalue = utils::numeric(FLERR, arg[4],false,lmp);
ystyle = CONSTANT;
}
if (strstr(arg[5], "v_") == arg[5]) {
zstr = utils::strdup( &arg[5][2]);
} else if (strcmp(arg[5], "NULL") == 0) {
zstyle = NONE;
} else {
zvalue = utils::numeric(FLERR, arg[5],false,lmp);
zstyle = CONSTANT;
}
// optional args
// optional args
int iarg = 6;
while (iarg < narg) {
if (strcmp(arg[iarg], "region") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix setvelocity command");
region = domain->get_region_by_id(arg[iarg + 1]);
if (!region) error->all(FLERR, "Region {} for fix setvelocity does not exist", arg[iarg + 1]);
idregion = utils::strdup(arg[iarg + 1]);
iarg += 2;
} else
error->all(FLERR, "Illegal fix setvelocity command");
}
iregion = -1;
idregion = nullptr;
force_flag = 0;
foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
int iarg = 6;
while (iarg < narg) {
if (strcmp(arg[iarg], "region") == 0) {
if (iarg + 2 > narg)
error->all(FLERR, "Illegal fix setvelocity command");
iregion = domain->find_region(arg[iarg + 1]);
if (iregion == -1)
error->all(FLERR, "Region ID for fix setvelocity does not exist");
idregion = utils::strdup( arg[iarg + 1]);
iarg += 2;
} else
error->all(FLERR, "Illegal fix setvelocity command");
}
force_flag = 0;
foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
maxatom = atom->nmax;
memory->create(sforce, maxatom, 3, "setvelocity:sforce");
maxatom = atom->nmax;
memory->create(sforce, maxatom, 3, "setvelocity:sforce");
}
/* ---------------------------------------------------------------------- */
FixSMDSetVel::~FixSMDSetVel() {
delete[] xstr;
delete[] ystr;
delete[] zstr;
delete[] idregion;
memory->destroy(sforce);
FixSMDSetVel::~FixSMDSetVel()
{
delete[] xstr;
delete[] ystr;
delete[] zstr;
delete[] idregion;
memory->destroy(sforce);
}
/* ---------------------------------------------------------------------- */
int FixSMDSetVel::setmask() {
int mask = 0;
//mask |= INITIAL_INTEGRATE;
mask |= POST_FORCE;
return mask;
int FixSMDSetVel::setmask()
{
int mask = 0;
mask |= POST_FORCE;
return mask;
}
/* ---------------------------------------------------------------------- */
void FixSMDSetVel::init() {
// check variables
void FixSMDSetVel::init()
{
// check variables
if (xstr) {
xvar = input->variable->find(xstr);
if (xvar < 0)
error->all(FLERR, "Variable name for fix setvelocity does not exist");
if (input->variable->equalstyle(xvar))
xstyle = EQUAL;
else if (input->variable->atomstyle(xvar))
xstyle = ATOM;
else
error->all(FLERR, "Variable for fix setvelocity is invalid style");
}
if (ystr) {
yvar = input->variable->find(ystr);
if (yvar < 0)
error->all(FLERR, "Variable name for fix setvelocity does not exist");
if (input->variable->equalstyle(yvar))
ystyle = EQUAL;
else if (input->variable->atomstyle(yvar))
ystyle = ATOM;
else
error->all(FLERR, "Variable for fix setvelocity is invalid style");
}
if (zstr) {
zvar = input->variable->find(zstr);
if (zvar < 0)
error->all(FLERR, "Variable name for fix setvelocity does not exist");
if (input->variable->equalstyle(zvar))
zstyle = EQUAL;
else if (input->variable->atomstyle(zvar))
zstyle = ATOM;
else
error->all(FLERR, "Variable for fix setvelocity is invalid style");
}
if (xstr) {
xvar = input->variable->find(xstr);
if (xvar < 0) error->all(FLERR, "Variable name for fix setvelocity does not exist");
if (input->variable->equalstyle(xvar))
xstyle = EQUAL;
else if (input->variable->atomstyle(xvar))
xstyle = ATOM;
else
error->all(FLERR, "Variable for fix setvelocity is invalid style");
}
if (ystr) {
yvar = input->variable->find(ystr);
if (yvar < 0) error->all(FLERR, "Variable name for fix setvelocity does not exist");
if (input->variable->equalstyle(yvar))
ystyle = EQUAL;
else if (input->variable->atomstyle(yvar))
ystyle = ATOM;
else
error->all(FLERR, "Variable for fix setvelocity is invalid style");
}
if (zstr) {
zvar = input->variable->find(zstr);
if (zvar < 0) error->all(FLERR, "Variable name for fix setvelocity does not exist");
if (input->variable->equalstyle(zvar))
zstyle = EQUAL;
else if (input->variable->atomstyle(zvar))
zstyle = ATOM;
else
error->all(FLERR, "Variable for fix setvelocity is invalid style");
}
// set index and check validity of region
// set index and check validity of region
if (iregion >= 0) {
iregion = domain->find_region(idregion);
if (iregion == -1)
error->all(FLERR, "Region ID for fix setvelocity does not exist");
}
if (idregion) {
region = domain->get_region_by_id(idregion);
if (!region) error->all(FLERR, "Region {} for fix setvelocity does not exist", idregion);
}
if (xstyle == ATOM || ystyle == ATOM || zstyle == ATOM)
varflag = ATOM;
else if (xstyle == EQUAL || ystyle == EQUAL || zstyle == EQUAL)
varflag = EQUAL;
else
varflag = CONSTANT;
if (xstyle == ATOM || ystyle == ATOM || zstyle == ATOM)
varflag = ATOM;
else if (xstyle == EQUAL || ystyle == EQUAL || zstyle == EQUAL)
varflag = EQUAL;
else
varflag = CONSTANT;
// cannot use non-zero forces for a minimization since no energy is integrated
// use fix addforce instead
// cannot use non-zero forces for a minimization since no energy is integrated
// use fix addforce instead
int flag = 0;
if (update->whichflag == 2) {
if (xstyle == EQUAL || xstyle == ATOM)
flag = 1;
if (ystyle == EQUAL || ystyle == ATOM)
flag = 1;
if (zstyle == EQUAL || zstyle == ATOM)
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)
error->all(FLERR, "Cannot use non-zero forces in an energy minimization");
int flag = 0;
if (update->whichflag == 2) {
if (xstyle == EQUAL || xstyle == ATOM) flag = 1;
if (ystyle == EQUAL || ystyle == ATOM) flag = 1;
if (zstyle == EQUAL || zstyle == ATOM) 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) error->all(FLERR, "Cannot use non-zero forces in an energy minimization");
}
/* ---------------------------------------------------------------------- */
void FixSMDSetVel::setup(int vflag) {
if (utils::strmatch(update->integrate_style,"^verlet"))
post_force(vflag);
else
error->all(FLERR,"Fix smd/setvel does not support RESPA");
void FixSMDSetVel::setup(int vflag)
{
if (utils::strmatch(update->integrate_style, "^verlet"))
post_force(vflag);
else
error->all(FLERR, "Fix smd/setvel does not support RESPA");
}
/* ---------------------------------------------------------------------- */
void FixSMDSetVel::min_setup(int vflag) {
post_force(vflag);
void FixSMDSetVel::min_setup(int vflag)
{
post_force(vflag);
}
/* ---------------------------------------------------------------------- */
//void FixSMDSetVel::initial_integrate(int vflag) {
void FixSMDSetVel::post_force(int /*vflag*/) {
double **x = atom->x;
double **f = atom->f;
double **v = atom->v;
double **vest = atom->vest;
int *mask = atom->mask;
int nlocal = atom->nlocal;
void FixSMDSetVel::post_force(int /*vflag*/)
{
double **x = atom->x;
double **f = atom->f;
double **v = atom->v;
double **vest = atom->vest;
int *mask = atom->mask;
int nlocal = atom->nlocal;
// update region if necessary
// update region if necessary
Region *region = nullptr;
if (iregion >= 0) {
region = domain->regions[iregion];
region->prematch();
if (region) region->prematch();
// reallocate sforce array if necessary
if (varflag == ATOM && atom->nmax > maxatom) {
maxatom = atom->nmax;
memory->destroy(sforce);
memory->create(sforce, maxatom, 3, "setvelocity:sforce");
}
foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
force_flag = 0;
if (varflag == CONSTANT) {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
if (region && !region->match(x[i][0], x[i][1], x[i][2])) continue;
foriginal[0] += f[i][0];
foriginal[1] += f[i][1];
foriginal[2] += f[i][2];
if (xstyle) {
v[i][0] = xvalue;
vest[i][0] = xvalue;
f[i][0] = 0.0;
}
if (ystyle) {
v[i][1] = yvalue;
vest[i][1] = yvalue;
f[i][1] = 0.0;
}
if (zstyle) {
v[i][2] = zvalue;
vest[i][2] = zvalue;
f[i][2] = 0.0;
}
}
// variable force, wrap with clear/add
} else {
modify->clearstep_compute();
if (xstyle == EQUAL)
xvalue = input->variable->compute_equal(xvar);
else if (xstyle == ATOM)
input->variable->compute_atom(xvar, igroup, &sforce[0][0], 3, 0);
if (ystyle == EQUAL)
yvalue = input->variable->compute_equal(yvar);
else if (ystyle == ATOM)
input->variable->compute_atom(yvar, igroup, &sforce[0][1], 3, 0);
if (zstyle == EQUAL)
zvalue = input->variable->compute_equal(zvar);
else if (zstyle == ATOM)
input->variable->compute_atom(zvar, igroup, &sforce[0][2], 3, 0);
modify->addstep_compute(update->ntimestep + 1);
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
if (region && !region->match(x[i][0], x[i][1], x[i][2])) continue;
foriginal[0] += f[i][0];
foriginal[1] += f[i][1];
foriginal[2] += f[i][2];
if (xstyle == ATOM) {
vest[i][0] = v[i][0] = sforce[i][0];
f[i][0] = 0.0;
} else if (xstyle) {
vest[i][0] = v[i][0] = xvalue;
f[i][0] = 0.0;
}
// reallocate sforce array if necessary
if (varflag == ATOM && atom->nmax > maxatom) {
maxatom = atom->nmax;
memory->destroy(sforce);
memory->create(sforce, maxatom, 3, "setvelocity:sforce");
if (ystyle == ATOM) {
vest[i][1] = v[i][1] = sforce[i][1];
f[i][1] = 0.0;
} else if (ystyle) {
vest[i][1] = v[i][1] = yvalue;
f[i][1] = 0.0;
}
foriginal[0] = foriginal[1] = foriginal[2] = 0.0;
force_flag = 0;
if (varflag == CONSTANT) {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
if (region && !region->match(x[i][0], x[i][1], x[i][2]))
continue;
foriginal[0] += f[i][0];
foriginal[1] += f[i][1];
foriginal[2] += f[i][2];
if (xstyle) {
v[i][0] = xvalue;
vest[i][0] = xvalue;
f[i][0] = 0.0;
}
if (ystyle) {
v[i][1] = yvalue;
vest[i][1] = yvalue;
f[i][1] = 0.0;
}
if (zstyle) {
v[i][2] = zvalue;
vest[i][2] = zvalue;
f[i][2] = 0.0;
}
}
// variable force, wrap with clear/add
} else {
modify->clearstep_compute();
if (xstyle == EQUAL)
xvalue = input->variable->compute_equal(xvar);
else if (xstyle == ATOM)
input->variable->compute_atom(xvar, igroup, &sforce[0][0], 3, 0);
if (ystyle == EQUAL)
yvalue = input->variable->compute_equal(yvar);
else if (ystyle == ATOM)
input->variable->compute_atom(yvar, igroup, &sforce[0][1], 3, 0);
if (zstyle == EQUAL)
zvalue = input->variable->compute_equal(zvar);
else if (zstyle == ATOM)
input->variable->compute_atom(zvar, igroup, &sforce[0][2], 3, 0);
modify->addstep_compute(update->ntimestep + 1);
//printf("setting velocity at timestep %d\n", update->ntimestep);
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
if (region && !region->match(x[i][0], x[i][1], x[i][2]))
continue;
foriginal[0] += f[i][0];
foriginal[1] += f[i][1];
foriginal[2] += f[i][2];
if (xstyle == ATOM) {
vest[i][0] = v[i][0] = sforce[i][0];
f[i][0] = 0.0;
} else if (xstyle) {
vest[i][0] = v[i][0] = xvalue;
f[i][0] = 0.0;
}
if (ystyle == ATOM) {
vest[i][1] = v[i][1] = sforce[i][1];
f[i][1] = 0.0;
} else if (ystyle) {
vest[i][1] = v[i][1] = yvalue;
f[i][1] = 0.0;
}
if (zstyle == ATOM) {
vest[i][2] = v[i][2] = sforce[i][2];
f[i][2] = 0.0;
} else if (zstyle) {
vest[i][2] = v[i][2] = zvalue;
f[i][2] = 0.0;
}
}
if (zstyle == ATOM) {
vest[i][2] = v[i][2] = sforce[i][2];
f[i][2] = 0.0;
} else if (zstyle) {
vest[i][2] = v[i][2] = zvalue;
f[i][2] = 0.0;
}
}
}
}
/* ----------------------------------------------------------------------
return components of total force on fix group before force was changed
------------------------------------------------------------------------- */
double FixSMDSetVel::compute_vector(int n) {
// only sum across procs one time
double FixSMDSetVel::compute_vector(int n)
{
// only sum across procs one time
if (force_flag == 0) {
MPI_Allreduce(foriginal, foriginal_all, 3, MPI_DOUBLE, MPI_SUM, world);
force_flag = 1;
}
return foriginal_all[n];
if (force_flag == 0) {
MPI_Allreduce(foriginal, foriginal_all, 3, MPI_DOUBLE, MPI_SUM, world);
force_flag = 1;
}
return foriginal_all[n];
}
/* ----------------------------------------------------------------------
memory usage of local atom-based array
------------------------------------------------------------------------- */
double FixSMDSetVel::memory_usage() {
double bytes = 0.0;
if (varflag == ATOM)
bytes = atom->nmax * 3 * sizeof(double);
return bytes;
double FixSMDSetVel::memory_usage()
{
double bytes = 0.0;
if (varflag == ATOM) bytes = atom->nmax * 3 * sizeof(double);
return bytes;
}

View File

@ -50,9 +50,10 @@ class FixSMDSetVel : public Fix {
private:
double xvalue, yvalue, zvalue;
int varflag, iregion;
int varflag;
char *xstr, *ystr, *zstr;
char *idregion;
class Region *region;
int xvar, yvar, zvar, xstyle, ystyle, zstyle;
double foriginal[3], foriginal_all[3];
int force_flag;

View File

@ -37,6 +37,7 @@ namespace user_manifold {
int nparams() override { return NPARAMS; }
void post_param_init() override;
private:
void init_domains();

View File

@ -369,7 +369,7 @@ void PairEDIP::compute(int eflag, int vflag)
directorCos_ik_z = invR_ik * dr_ik[2];
cosTeta = directorCos_ij_x * directorCos_ik_x + directorCos_ij_y * directorCos_ik_y +
directorCos_ij_z * directorCos_ik_z;
directorCos_ij_z * directorCos_ik_z;
cosTetaDiff = cosTeta + tauFunction;
cosTetaDiffCosTetaDiff = cosTetaDiff * cosTetaDiff;
@ -377,33 +377,33 @@ void PairEDIP::compute(int eflag, int vflag)
expMinusQFunctionCosTetaDiffCosTetaDiff = exp(-qFunctionCosTetaDiffCosTetaDiff);
potentia3B_factor = lambda *
((1.0 - expMinusQFunctionCosTetaDiffCosTetaDiff) +
eta * qFunctionCosTetaDiffCosTetaDiff);
((1.0 - expMinusQFunctionCosTetaDiffCosTetaDiff) +
eta * qFunctionCosTetaDiffCosTetaDiff);
exp3B_ik = preExp3B_ij[neighbor_k];
exp3BDerived_ik = preExp3BDerived_ij[neighbor_k];
forceMod3B_factor1_ij = -exp3BDerived_ij * exp3B_ik * potentia3B_factor;
forceMod3B_factor2 = 2.0 * lambda * exp3B_ij * exp3B_ik * qFunction * cosTetaDiff *
(eta + expMinusQFunctionCosTetaDiffCosTetaDiff);
(eta + expMinusQFunctionCosTetaDiffCosTetaDiff);
forceMod3B_factor2_ij = forceMod3B_factor2 * invR_ij;
f_ij[0] = forceMod3B_factor1_ij * directorCos_ij_x +
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_x - directorCos_ik_x);
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_x - directorCos_ik_x);
f_ij[1] = forceMod3B_factor1_ij * directorCos_ij_y +
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_y - directorCos_ik_y);
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_y - directorCos_ik_y);
f_ij[2] = forceMod3B_factor1_ij * directorCos_ij_z +
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_z - directorCos_ik_z);
forceMod3B_factor2_ij * (cosTeta * directorCos_ij_z - directorCos_ik_z);
forceMod3B_factor1_ik = -exp3BDerived_ik * exp3B_ij * potentia3B_factor;
forceMod3B_factor2_ik = forceMod3B_factor2 * invR_ik;
f_ik[0] = forceMod3B_factor1_ik * directorCos_ik_x +
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_x - directorCos_ij_x);
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_x - directorCos_ij_x);
f_ik[1] = forceMod3B_factor1_ik * directorCos_ik_y +
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_y - directorCos_ij_y);
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_y - directorCos_ij_y);
f_ik[2] = forceMod3B_factor1_ik * directorCos_ik_z +
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_z - directorCos_ij_z);
forceMod3B_factor2_ik * (cosTeta * directorCos_ik_z - directorCos_ij_z);
forceModCoord += (forceMod3B_factor2 * (tauFunctionDerived - 0.5 * mu * cosTetaDiff));
@ -800,13 +800,12 @@ void PairEDIP::read_file(char *file)
if (nparams == maxparam) {
maxparam += DELTA;
params = (Param *) memory->srealloc(params,maxparam*sizeof(Param),
"pair:params");
params = (Param *) memory->srealloc(params, maxparam * sizeof(Param), "pair:params");
// make certain all addional allocated storage is initialized
// to avoid false positives when checking with valgrind
memset(params + nparams, 0, DELTA*sizeof(Param));
memset(params + nparams, 0, DELTA * sizeof(Param));
}
params[nparams].ielement = ielement;
@ -847,9 +846,9 @@ void PairEDIP::read_file(char *file)
MPI_Bcast(&maxparam, 1, MPI_INT, 0, world);
if (comm->me != 0)
params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params");
params = (Param *) memory->srealloc(params, maxparam * sizeof(Param), "pair:params");
MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world);
MPI_Bcast(params, maxparam * sizeof(Param), MPI_BYTE, 0, world);
}
/* ---------------------------------------------------------------------- */

View File

@ -50,7 +50,7 @@ class PairEDIP : public Pair {
double mu, Q0; // coefficients for function Q(Z)
double u1, u2, u3, u4; // coefficients for function tau(Z)
double cutsq;
int ielement, jelement, kelement, dummy; // dummy added for better alignment
int ielement, jelement, kelement, dummy; // dummy added for better alignment
};
double *preInvR_ij;

View File

@ -50,7 +50,7 @@ class PairEDIPMulti : public Pair {
double mu, Q0; // coefficients for function Q(Z)
double u1, u2, u3, u4; // coefficients for function tau(Z)
double cutsq;
int ielement, jelement, kelement, dummy; // dummy added for better alignment
int ielement, jelement, kelement, dummy; // dummy added for better alignment
};
double *preForceCoord;

View File

@ -58,8 +58,8 @@ class PairSW : public Pair {
void read_file(char *);
virtual void setup_params();
void twobody(Param *, double, double &, int, double &);
virtual void threebody(Param *, Param *, Param *, double, double, double *, double *, double *, double *,
int, double &);
virtual void threebody(Param *, Param *, Param *, double, double, double *, double *, double *,
double *, int, double &);
};
} // namespace LAMMPS_NS

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -40,9 +39,9 @@
#include "region.h"
#include "update.h"
#include <cmath>
#include <cctype>
#include <cfloat>
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
@ -51,13 +50,12 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixAtomSwap::FixAtomSwap(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
idregion(nullptr), type_list(nullptr), mu(nullptr), qtype(nullptr),
sqrt_mass_ratio(nullptr), local_swap_iatom_list(nullptr),
local_swap_jatom_list(nullptr), local_swap_atom_list(nullptr),
random_equal(nullptr), random_unequal(nullptr), c_pe(nullptr)
Fix(lmp, narg, arg), region(nullptr), idregion(nullptr), type_list(nullptr), mu(nullptr),
qtype(nullptr), sqrt_mass_ratio(nullptr), local_swap_iatom_list(nullptr),
local_swap_jatom_list(nullptr), local_swap_atom_list(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");
dynamic_group_allow = 1;
@ -70,33 +68,33 @@ FixAtomSwap::FixAtomSwap(LAMMPS *lmp, int narg, char **arg) :
// required args
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
ncycles = utils::inumeric(FLERR,arg[4],false,lmp);
seed = utils::inumeric(FLERR,arg[5],false,lmp);
double temperature = utils::numeric(FLERR,arg[6],false,lmp);
nevery = utils::inumeric(FLERR, arg[3], false, lmp);
ncycles = utils::inumeric(FLERR, arg[4], false, lmp);
seed = utils::inumeric(FLERR, arg[5], false, lmp);
double temperature = utils::numeric(FLERR, arg[6], false, lmp);
if (nevery <= 0) error->all(FLERR,"Illegal fix atom/swap command");
if (ncycles < 0) error->all(FLERR,"Illegal fix atom/swap command");
if (seed <= 0) error->all(FLERR,"Illegal fix atom/swap command");
if (temperature <= 0.0) error->all(FLERR,"Illegal fix atom/swap command");
if (nevery <= 0) error->all(FLERR, "Illegal fix atom/swap command");
if (ncycles < 0) error->all(FLERR, "Illegal fix atom/swap command");
if (seed <= 0) error->all(FLERR, "Illegal fix atom/swap command");
if (temperature <= 0.0) error->all(FLERR, "Illegal fix atom/swap command");
beta = 1.0/(force->boltz*temperature);
beta = 1.0 / (force->boltz * temperature);
memory->create(type_list,atom->ntypes,"atom/swap:type_list");
memory->create(mu,atom->ntypes+1,"atom/swap:mu");
memory->create(type_list, atom->ntypes, "atom/swap:type_list");
memory->create(mu, atom->ntypes + 1, "atom/swap:mu");
for (int i = 1; i <= atom->ntypes; i++) mu[i] = 0.0;
// read options from end of input line
options(narg-7,&arg[7]);
options(narg - 7, &arg[7]);
// random number generator, same for all procs
random_equal = new RanPark(lmp,seed);
random_equal = new RanPark(lmp, seed);
// random number generator, not the same for all procs
random_unequal = new RanPark(lmp,seed);
random_unequal = new RanPark(lmp, seed);
// set up reneighboring
@ -115,9 +113,10 @@ FixAtomSwap::FixAtomSwap(LAMMPS *lmp, int narg, char **arg) :
// set comm size needed by this Fix
if (atom->q_flag) comm_forward = 2;
else comm_forward = 1;
if (atom->q_flag)
comm_forward = 2;
else
comm_forward = 1;
}
/* ---------------------------------------------------------------------- */
@ -130,7 +129,7 @@ FixAtomSwap::~FixAtomSwap()
memory->destroy(sqrt_mass_ratio);
memory->destroy(local_swap_iatom_list);
memory->destroy(local_swap_jatom_list);
if (regionflag) delete [] idregion;
delete[] idregion;
delete random_equal;
delete random_unequal;
}
@ -141,54 +140,51 @@ FixAtomSwap::~FixAtomSwap()
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;
semi_grand_flag = 0;
nswaptypes = 0;
nmutypes = 0;
iregion = -1;
int iarg = 0;
while (iarg < narg) {
if (strcmp(arg[iarg],"region") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix atom/swap command");
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix atom/swap does not exist");
idregion = utils::strdup(arg[iarg+1]);
regionflag = 1;
if (strcmp(arg[iarg], "region") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix atom/swap command");
region = domain->get_region_by_id(arg[iarg + 1]);
if (!region) error->all(FLERR, "Region {} for fix atom/swap does not exist", arg[iarg + 1]);
idregion = utils::strdup(arg[iarg + 1]);
iarg += 2;
} else if (strcmp(arg[iarg],"ke") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix atom/swap command");
ke_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
} else if (strcmp(arg[iarg], "ke") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix atom/swap command");
ke_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"semi-grand") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix atom/swap command");
semi_grand_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
} else if (strcmp(arg[iarg], "semi-grand") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix atom/swap command");
semi_grand_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"types") == 0) {
if (iarg+3 > narg) error->all(FLERR,"Illegal fix atom/swap command");
} else if (strcmp(arg[iarg], "types") == 0) {
if (iarg + 3 > narg) error->all(FLERR, "Illegal fix atom/swap command");
iarg++;
while (iarg < narg) {
if (isalpha(arg[iarg][0])) break;
if (nswaptypes >= atom->ntypes) error->all(FLERR,"Illegal fix atom/swap command");
type_list[nswaptypes] = utils::numeric(FLERR,arg[iarg],false,lmp);
if (nswaptypes >= atom->ntypes) error->all(FLERR, "Illegal fix atom/swap command");
type_list[nswaptypes] = utils::numeric(FLERR, arg[iarg], false, lmp);
nswaptypes++;
iarg++;
}
} else if (strcmp(arg[iarg],"mu") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix atom/swap command");
} else if (strcmp(arg[iarg], "mu") == 0) {
if (iarg + 2 > narg) error->all(FLERR, "Illegal fix atom/swap command");
iarg++;
while (iarg < narg) {
if (isalpha(arg[iarg][0])) break;
nmutypes++;
if (nmutypes > atom->ntypes) error->all(FLERR,"Illegal fix atom/swap command");
mu[nmutypes] = utils::numeric(FLERR,arg[iarg],false,lmp);
if (nmutypes > atom->ntypes) error->all(FLERR, "Illegal fix atom/swap command");
mu[nmutypes] = utils::numeric(FLERR, arg[iarg], false, lmp);
iarg++;
}
} else error->all(FLERR,"Illegal fix atom/swap command");
} else
error->all(FLERR, "Illegal fix atom/swap command");
}
}
@ -205,36 +201,40 @@ int FixAtomSwap::setmask()
void FixAtomSwap::init()
{
auto id_pe = (char *) "thermo_pe";
int ipe = modify->find_compute(id_pe);
c_pe = modify->compute[ipe];
c_pe = modify->get_compute_by_id("thermo_pe");
int *type = atom->type;
if (nswaptypes < 2)
error->all(FLERR,"Must specify at least 2 types in fix atom/swap command");
if (nswaptypes < 2) error->all(FLERR, "Must specify at least 2 types in fix atom/swap command");
if (semi_grand_flag) {
if (nswaptypes != nmutypes)
error->all(FLERR,"Need nswaptypes mu values in fix atom/swap command");
error->all(FLERR, "Need nswaptypes mu values in fix atom/swap command");
} else {
if (nswaptypes != 2)
error->all(FLERR,"Only 2 types allowed when not using semi-grand in fix atom/swap command");
error->all(FLERR, "Only 2 types allowed when not using semi-grand in fix atom/swap command");
if (nmutypes != 0)
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++)
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");
// this is only required for non-semi-grand
// in which case, nswaptypes = 2
if (atom->q_flag && !semi_grand_flag) {
double qmax,qmin;
int firstall,first;
memory->create(qtype,nswaptypes,"atom/swap:qtype");
double qmax, qmin;
int firstall, first;
memory->create(qtype, nswaptypes, "atom/swap:qtype");
for (int iswaptype = 0; iswaptype < nswaptypes; iswaptype++) {
first = 1;
for (int i = 0; i < atom->nlocal; i++) {
@ -244,24 +244,26 @@ void FixAtomSwap::init()
qtype[iswaptype] = atom->q[i];
first = 0;
} else if (qtype[iswaptype] != atom->q[i])
error->one(FLERR,"All atoms of a swapped type must have the same charge.");
error->one(FLERR, "All atoms of a swapped type must have the same charge.");
}
}
}
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.");
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 (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;
MPI_Allreduce(&qtype[iswaptype],&qmin,1,MPI_DOUBLE,MPI_MIN,world);
if (qmax != qmin) error->all(FLERR,"All atoms of a swapped type must have same charge.");
MPI_Allreduce(&qtype[iswaptype], &qmin, 1, MPI_DOUBLE, MPI_MIN, world);
if (qmax != qmin) error->all(FLERR, "All atoms of a swapped type must have same charge.");
}
}
memory->create(sqrt_mass_ratio,atom->ntypes+1,atom->ntypes+1,"atom/swap:sqrt_mass_ratio");
memory->create(sqrt_mass_ratio, atom->ntypes + 1, atom->ntypes + 1, "atom/swap:sqrt_mass_ratio");
for (int itype = 1; itype <= atom->ntypes; itype++)
for (int jtype = 1; jtype <= atom->ntypes; jtype++)
sqrt_mass_ratio[itype][jtype] = sqrt(atom->mass[itype]/atom->mass[jtype]);
sqrt_mass_ratio[itype][jtype] = sqrt(atom->mass[itype] / atom->mass[jtype]);
// check to see if itype and jtype cutoffs are the same
// if not, reneighboring will be needed between swaps
@ -286,10 +288,9 @@ void FixAtomSwap::init()
if ((mask[i] == groupbit) && (mask[i] && firstgroupbit)) flag = 1;
int flagall;
MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world);
MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world);
if (flagall)
error->all(FLERR,"Cannot do atom/swap on atoms in atom_modify first group");
if (flagall) error->all(FLERR, "Cannot do atom/swap on atoms in atom_modify first group");
}
}
@ -309,7 +310,7 @@ void FixAtomSwap::pre_exchange()
domain->pbc();
comm->exchange();
comm->borders();
if (domain->triclinic) domain->lamda2x(atom->nlocal+atom->nghost);
if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost);
if (modify->n_pre_neighbor) modify->pre_neighbor();
neighbor->build(1);
@ -353,14 +354,14 @@ int FixAtomSwap::attempt_semi_grand()
// pick a random atom and perform swap
int itype,jtype,jswaptype;
int itype, jtype, jswaptype;
int i = pick_semi_grand_atom();
if (i >= 0) {
jswaptype = static_cast<int> (nswaptypes*random_unequal->uniform());
jswaptype = static_cast<int>(nswaptypes * random_unequal->uniform());
jtype = type_list[jswaptype];
itype = atom->type[i];
while (itype == jtype) {
jswaptype = static_cast<int> (nswaptypes*random_unequal->uniform());
jswaptype = static_cast<int>(nswaptypes * random_unequal->uniform());
jtype = type_list[jswaptype];
}
atom->type[i] = jtype;
@ -374,7 +375,7 @@ int FixAtomSwap::attempt_semi_grand()
if (domain->triclinic) domain->x2lamda(atom->nlocal);
comm->exchange();
comm->borders();
if (domain->triclinic) domain->lamda2x(atom->nlocal+atom->nghost);
if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost);
if (modify->n_pre_neighbor) modify->pre_neighbor();
neighbor->build(1);
} else {
@ -389,11 +390,11 @@ int FixAtomSwap::attempt_semi_grand()
int success = 0;
if (i >= 0)
if (random_unequal->uniform() <
exp(beta*(energy_before - energy_after
+ mu[jtype] - mu[itype]))) success = 1;
exp(beta * (energy_before - energy_after + mu[jtype] - mu[itype])))
success = 1;
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);
// swap accepted, return 1
@ -460,7 +461,7 @@ int FixAtomSwap::attempt_swap()
domain->pbc();
comm->exchange();
comm->borders();
if (domain->triclinic) domain->lamda2x(atom->nlocal+atom->nghost);
if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost);
if (modify->n_pre_neighbor) modify->pre_neighbor();
neighbor->build(1);
} else {
@ -474,8 +475,7 @@ int FixAtomSwap::attempt_swap()
// swap accepted, return 1
// if ke_flag, rescale atom velocities
if (random_equal->uniform() <
exp(beta*(energy_before - energy_after))) {
if (random_equal->uniform() < exp(beta * (energy_before - energy_after))) {
update_swap_atoms_list();
if (ke_flag) {
if (i >= 0) {
@ -521,16 +521,16 @@ double FixAtomSwap::energy_full()
if (modify->n_pre_force) modify->pre_force(vflag);
if (force->pair) force->pair->compute(eflag,vflag);
if (force->pair) force->pair->compute(eflag, vflag);
if (atom->molecular != Atom::ATOMIC) {
if (force->bond) force->bond->compute(eflag,vflag);
if (force->angle) force->angle->compute(eflag,vflag);
if (force->dihedral) force->dihedral->compute(eflag,vflag);
if (force->improper) force->improper->compute(eflag,vflag);
if (force->bond) force->bond->compute(eflag, vflag);
if (force->angle) force->angle->compute(eflag, vflag);
if (force->dihedral) force->dihedral->compute(eflag, vflag);
if (force->improper) force->improper->compute(eflag, vflag);
}
if (force->kspace) force->kspace->compute(eflag,vflag);
if (force->kspace) force->kspace->compute(eflag, vflag);
if (modify->n_post_force_any) modify->post_force(vflag);
@ -546,9 +546,8 @@ double FixAtomSwap::energy_full()
int FixAtomSwap::pick_semi_grand_atom()
{
int i = -1;
int iwhichglobal = static_cast<int> (nswap*random_equal->uniform());
if ((iwhichglobal >= nswap_before) &&
(iwhichglobal < nswap_before + nswap_local)) {
int iwhichglobal = static_cast<int>(nswap * random_equal->uniform());
if ((iwhichglobal >= nswap_before) && (iwhichglobal < nswap_before + nswap_local)) {
int iwhichlocal = iwhichglobal - nswap_before;
i = local_swap_atom_list[iwhichlocal];
}
@ -562,9 +561,8 @@ int FixAtomSwap::pick_semi_grand_atom()
int FixAtomSwap::pick_i_swap_atom()
{
int i = -1;
int iwhichglobal = static_cast<int> (niswap*random_equal->uniform());
if ((iwhichglobal >= niswap_before) &&
(iwhichglobal < niswap_before + niswap_local)) {
int iwhichglobal = static_cast<int>(niswap * random_equal->uniform());
if ((iwhichglobal >= niswap_before) && (iwhichglobal < niswap_before + niswap_local)) {
int iwhichlocal = iwhichglobal - niswap_before;
i = local_swap_iatom_list[iwhichlocal];
}
@ -578,9 +576,8 @@ int FixAtomSwap::pick_i_swap_atom()
int FixAtomSwap::pick_j_swap_atom()
{
int j = -1;
int jwhichglobal = static_cast<int> (njswap*random_equal->uniform());
if ((jwhichglobal >= njswap_before) &&
(jwhichglobal < njswap_before + njswap_local)) {
int jwhichglobal = static_cast<int>(njswap * random_equal->uniform());
if ((jwhichglobal >= njswap_before) && (jwhichglobal < njswap_before + njswap_local)) {
int jwhichlocal = jwhichglobal - njswap_before;
j = local_swap_jatom_list[jwhichlocal];
}
@ -600,16 +597,15 @@ void FixAtomSwap::update_semi_grand_atoms_list()
if (atom->nmax > atom_swap_nmax) {
memory->sfree(local_swap_atom_list);
atom_swap_nmax = atom->nmax;
local_swap_atom_list = (int *) memory->smalloc(atom_swap_nmax*sizeof(int),
"MCSWAP:local_swap_atom_list");
local_swap_atom_list =
(int *) memory->smalloc(atom_swap_nmax * sizeof(int), "MCSWAP:local_swap_atom_list");
}
nswap_local = 0;
if (regionflag) {
if (region) {
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) {
int itype = atom->type[i];
int iswaptype;
@ -625,23 +621,22 @@ void FixAtomSwap::update_semi_grand_atoms_list()
} else {
for (int i = 0; i < nlocal; i++) {
if (atom->mask[i] & groupbit) {
int itype = atom->type[i];
int iswaptype;
for (iswaptype = 0; iswaptype < nswaptypes; iswaptype++)
if (itype == type_list[iswaptype]) break;
if (iswaptype == nswaptypes) continue;
int itype = atom->type[i];
int iswaptype;
for (iswaptype = 0; iswaptype < nswaptypes; iswaptype++)
if (itype == type_list[iswaptype]) break;
if (iswaptype == nswaptypes) continue;
local_swap_atom_list[nswap_local] = i;
nswap_local++;
}
}
}
MPI_Allreduce(&nswap_local,&nswap,1,MPI_INT,MPI_SUM,world);
MPI_Scan(&nswap_local,&nswap_before,1,MPI_INT,MPI_SUM,world);
MPI_Allreduce(&nswap_local, &nswap, 1, MPI_INT, MPI_SUM, world);
MPI_Scan(&nswap_local, &nswap_before, 1, MPI_INT, MPI_SUM, world);
nswap_before -= nswap_local;
}
/* ----------------------------------------------------------------------
update the list of gas atoms
------------------------------------------------------------------------- */
@ -656,24 +651,24 @@ void FixAtomSwap::update_swap_atoms_list()
memory->sfree(local_swap_iatom_list);
memory->sfree(local_swap_jatom_list);
atom_swap_nmax = atom->nmax;
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),
"MCSWAP:local_swap_jatom_list");
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), "MCSWAP:local_swap_jatom_list");
}
niswap_local = 0;
njswap_local = 0;
if (regionflag) {
if (region) {
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 (type[i] == type_list[0]) {
if (type[i] == type_list[0]) {
local_swap_iatom_list[niswap_local] = i;
niswap_local++;
} else if (type[i] == type_list[1]) {
} else if (type[i] == type_list[1]) {
local_swap_jatom_list[njswap_local] = i;
njswap_local++;
}
@ -684,10 +679,10 @@ void FixAtomSwap::update_swap_atoms_list()
} else {
for (int i = 0; i < nlocal; i++) {
if (atom->mask[i] & groupbit) {
if (type[i] == type_list[0]) {
if (type[i] == type_list[0]) {
local_swap_iatom_list[niswap_local] = i;
niswap_local++;
} else if (type[i] == type_list[1]) {
} else if (type[i] == type_list[1]) {
local_swap_jatom_list[njswap_local] = i;
njswap_local++;
}
@ -695,12 +690,12 @@ void FixAtomSwap::update_swap_atoms_list()
}
}
MPI_Allreduce(&niswap_local,&niswap,1,MPI_INT,MPI_SUM,world);
MPI_Scan(&niswap_local,&niswap_before,1,MPI_INT,MPI_SUM,world);
MPI_Allreduce(&niswap_local, &niswap, 1, MPI_INT, MPI_SUM, world);
MPI_Scan(&niswap_local, &niswap_before, 1, MPI_INT, MPI_SUM, world);
niswap_before -= niswap_local;
MPI_Allreduce(&njswap_local,&njswap,1,MPI_INT,MPI_SUM,world);
MPI_Scan(&njswap_local,&njswap_before,1,MPI_INT,MPI_SUM,world);
MPI_Allreduce(&njswap_local, &njswap, 1, MPI_INT, MPI_SUM, world);
MPI_Scan(&njswap_local, &njswap_before, 1, MPI_INT, MPI_SUM, world);
njswap_before -= njswap_local;
}
@ -708,7 +703,7 @@ void FixAtomSwap::update_swap_atoms_list()
int FixAtomSwap::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/)
{
int i,j,m;
int i, j, m;
int *type = atom->type;
double *q = atom->q;
@ -735,7 +730,7 @@ int FixAtomSwap::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag
void FixAtomSwap::unpack_forward_comm(int n, int first, double *buf)
{
int i,m,last;
int i, m, last;
int *type = atom->type;
double *q = atom->q;
@ -745,12 +740,11 @@ void FixAtomSwap::unpack_forward_comm(int n, int first, double *buf)
if (atom->q_flag) {
for (i = first; i < last; i++) {
type[i] = static_cast<int> (buf[m++]);
type[i] = static_cast<int>(buf[m++]);
q[i] = buf[m++];
}
} else {
for (i = first; i < last; i++)
type[i] = static_cast<int> (buf[m++]);
for (i = first; i < last; i++) type[i] = static_cast<int>(buf[m++]);
}
}
@ -771,7 +765,7 @@ double FixAtomSwap::compute_vector(int n)
double FixAtomSwap::memory_usage()
{
double bytes = (double)atom_swap_nmax * sizeof(int);
double bytes = (double) atom_swap_nmax * sizeof(int);
return bytes;
}
@ -792,8 +786,8 @@ void FixAtomSwap::write_restart(FILE *fp)
if (comm->me == 0) {
int size = n * sizeof(double);
fwrite(&size,sizeof(int),1,fp);
fwrite(list,sizeof(double),n,fp);
fwrite(&size, sizeof(int), 1, fp);
fwrite(list, sizeof(double), n, fp);
}
}
@ -806,10 +800,10 @@ void FixAtomSwap::restart(char *buf)
int n = 0;
auto list = (double *) buf;
seed = static_cast<int> (list[n++]);
seed = static_cast<int>(list[n++]);
random_equal->reset(seed);
seed = static_cast<int> (list[n++]);
seed = static_cast<int>(list[n++]);
random_unequal->reset(seed);
next_reneighbor = (bigint) ubuf(list[n++]).i;
@ -819,5 +813,5 @@ void FixAtomSwap::restart(char *buf)
bigint ntimestep_restart = (bigint) ubuf(list[n++]).i;
if (ntimestep_restart != update->ntimestep)
error->all(FLERR,"Must not reset timestep when restarting fix atom/swap");
error->all(FLERR, "Must not reset timestep when restarting fix atom/swap");
}

View File

@ -40,8 +40,8 @@ class FixAtomSwap : public Fix {
private:
int nevery, seed;
int ke_flag; // yes = conserve ke, no = do not conserve ke
int semi_grand_flag; // yes = semi-grand canonical, no = constant composition
int ke_flag; // yes = conserve ke, no = do not conserve ke
int semi_grand_flag; // yes = semi-grand canonical, no = constant composition
int ncycles;
int niswap, njswap; // # of i,j swap atoms on all procs
int niswap_local, njswap_local; // # of swap atoms on this proc
@ -49,8 +49,7 @@ class FixAtomSwap : public Fix {
int nswap; // # of swap atoms on all procs
int nswap_local; // # of swap atoms on this proc
int nswap_before; // # of swap atoms on procs < this proc
int regionflag; // 0 = anywhere in box, 1 = specific region
int iregion; // swap region
class Region *region; // swap region
char *idregion; // swap region id
int nswaptypes, nmutypes;

View File

@ -68,7 +68,7 @@ enum{NONE,MOVEATOM,MOVEMOL}; // movemode
FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **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),
molcoords(nullptr), molq(nullptr), molimage(nullptr), random_equal(nullptr), random_unequal(nullptr),
fixrigid(nullptr), fixshake(nullptr), idrigid(nullptr), idshake(nullptr)
@ -87,6 +87,9 @@ FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) :
restart_global = 1;
time_depend = 1;
ngroups = 0;
ngrouptypes = 0;
// required args
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_zlo = region_zhi = 0.0;
if (regionflag) {
if (domain->regions[iregion]->bboxflag == 0)
if (region) {
if (region->bboxflag == 0)
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");
region_xlo = domain->regions[iregion]->extent_xlo;
region_xhi = domain->regions[iregion]->extent_xhi;
region_ylo = domain->regions[iregion]->extent_ylo;
region_yhi = domain->regions[iregion]->extent_yhi;
region_zlo = domain->regions[iregion]->extent_zlo;
region_zhi = domain->regions[iregion]->extent_zhi;
region_xlo = region->extent_xlo;
region_xhi = region->extent_xhi;
region_ylo = region->extent_ylo;
region_yhi = region->extent_yhi;
region_zlo = region->extent_zlo;
region_zhi = region->extent_zhi;
if (region_xlo < domain->boxlo[0] || region_xhi > domain->boxhi[0] ||
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[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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++;
}
double max_region_volume = (region_xhi - region_xlo)*
(region_yhi - region_ylo)*(region_zhi - region_zlo);
double max_region_volume = (region_xhi - region_xlo) *
(region_yhi - region_ylo) * (region_zhi - region_zlo);
region_volume = max_region_volume*static_cast<double> (inside)/
static_cast<double> (attempts);
region_volume = max_region_volume * static_cast<double>(inside) / static_cast<double>(attempts);
}
// error check and further setup for exchmode = EXCHMOL
@ -241,8 +243,6 @@ void FixGCMC::options(int narg, char **arg)
pmolrotate = 0.0;
pmctot = 0.0;
max_rotation_angle = 10*MY_PI/180;
regionflag = 0;
iregion = -1;
region_volume = 0;
max_region_attempts = 1000;
molecule_group = 0;
@ -300,11 +300,10 @@ void FixGCMC::options(int narg, char **arg)
iarg += 4;
} else if (strcmp(arg[iarg],"region") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix gcmc does not exist");
region = domain->get_region_by_id(arg[iarg+1]);
if (!region)
error->all(FLERR,"Region {} for fix gcmc does not exist",arg[iarg+1]);
idregion = utils::strdup(arg[iarg+1]);
regionflag = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"maxangle") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix gcmc command");
@ -397,7 +396,7 @@ void FixGCMC::options(int narg, char **arg)
FixGCMC::~FixGCMC()
{
if (regionflag) delete [] idregion;
delete[] idregion;
delete random_equal;
delete random_unequal;
@ -406,12 +405,12 @@ FixGCMC::~FixGCMC()
memory->destroy(molq);
memory->destroy(molimage);
delete [] idrigid;
delete [] idshake;
delete[] idrigid;
delete[] idshake;
if (ngroups > 0) {
for (int igroup = 0; igroup < ngroups; igroup++)
delete [] groupstrings[igroup];
delete[] groupstrings[igroup];
memory->sfree(groupstrings);
}
@ -419,7 +418,7 @@ FixGCMC::~FixGCMC()
memory->destroy(grouptypes);
memory->destroy(grouptypebits);
for (int igroup = 0; igroup < ngrouptypes; igroup++)
delete [] grouptypestrings[igroup];
delete[] grouptypestrings[igroup];
memory->sfree(grouptypestrings);
}
if (full_flag && group) {
@ -443,6 +442,13 @@ int FixGCMC::setmask()
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;
// set probabilities for MC moves
@ -719,7 +725,7 @@ void FixGCMC::pre_exchange()
subhi = domain->subhi;
}
if (regionflag) volume = region_volume;
if (region) volume = region_volume;
else volume = domain->xprd * domain->yprd * domain->zprd;
if (triclinic) domain->x2lamda(atom->nlocal);
@ -801,8 +807,7 @@ void FixGCMC::attempt_atomic_translation()
double **x = atom->x;
double energy_before = energy(i,ngcmc_type,-1,x[i]);
if (overlap_flag && energy_before > MAXENERGYTEST)
error->warning(FLERR,"Energy of old configuration in "
"fix gcmc is > MAXENERGYTEST.");
error->warning(FLERR,"Energy of old configuration in fix gcmc is > MAXENERGYTEST.");
double rsq = 1.1;
double rx,ry,rz;
rx = ry = rz = 0.0;
@ -816,8 +821,8 @@ void FixGCMC::attempt_atomic_translation()
coord[0] = x[i][0] + displace*rx;
coord[1] = x[i][1] + displace*ry;
coord[2] = x[i][2] + displace*rz;
if (regionflag) {
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
if (region) {
while (region->match(coord[0],coord[1],coord[2]) == 0) {
rsq = 1.1;
while (rsq > 1.0) {
rx = 2*random_unequal->uniform() - 1.0;
@ -913,12 +918,12 @@ void FixGCMC::attempt_atomic_insertion()
// pick coordinates for insertion point
double coord[3];
if (regionflag) {
if (region) {
int region_attempt = 0;
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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[2] = displace*rz;
if (regionflag) {
if (region) {
int *mask = atom->mask;
for (int i = 0; i < atom->nlocal; i++) {
if (atom->molecule[i] == translation_molecule) {
@ -1058,7 +1063,7 @@ void FixGCMC::attempt_molecule_translation()
coord[0] = com[0] + displace*rx;
coord[1] = com[1] + displace*ry;
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;
while (rsq > 1.0) {
rx = 2*random_equal->uniform() - 1.0;
@ -1266,7 +1271,7 @@ void FixGCMC::attempt_molecule_insertion()
if (ngas >= max_ngas) return;
double com_coord[3];
if (regionflag) {
if (region) {
int region_attempt = 0;
com_coord[0] = region_xlo + random_equal->uniform() *
(region_xhi-region_xlo);
@ -1274,7 +1279,7 @@ void FixGCMC::attempt_molecule_insertion()
(region_yhi-region_ylo);
com_coord[2] = region_zlo + random_equal->uniform() *
(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[0] = region_xlo + random_equal->uniform() *
(region_xhi-region_xlo);
@ -1485,8 +1490,8 @@ void FixGCMC::attempt_atomic_translation_full()
coord[0] = x[i][0] + displace*rx;
coord[1] = x[i][1] + displace*ry;
coord[2] = x[i][2] + displace*rz;
if (regionflag) {
while (domain->regions[iregion]->match(coord[0],coord[1],coord[2]) == 0) {
if (region) {
while (region->match(coord[0],coord[1],coord[2]) == 0) {
rsq = 1.1;
while (rsq > 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 coord[3];
if (regionflag) {
if (region) {
int region_attempt = 0;
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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[2] = displace*rz;
if (regionflag) {
if (region) {
int *mask = atom->mask;
for (int i = 0; i < atom->nlocal; i++) {
if (atom->molecule[i] == translation_molecule) {
@ -1741,7 +1746,7 @@ void FixGCMC::attempt_molecule_translation_full()
coord[0] = com[0] + displace*rx;
coord[1] = com[1] + displace*ry;
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;
while (rsq > 1.0) {
rx = 2*random_equal->uniform() - 1.0;
@ -1998,7 +2003,7 @@ void FixGCMC::attempt_molecule_insertion_full()
int nlocalprev = atom->nlocal;
double com_coord[3];
if (regionflag) {
if (region) {
int region_attempt = 0;
com_coord[0] = region_xlo + random_equal->uniform() *
(region_xhi-region_xlo);
@ -2006,7 +2011,7 @@ void FixGCMC::attempt_molecule_insertion_full()
(region_yhi-region_ylo);
com_coord[2] = region_zlo + random_equal->uniform() *
(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[0] = region_xlo + random_equal->uniform() *
(region_xhi-region_xlo);
@ -2408,7 +2413,7 @@ void FixGCMC::update_gas_atoms_list()
ngas_local = 0;
if (regionflag) {
if (region) {
if (exchmode == EXCHMOL || movemode == MOVEMOL) {
@ -2441,7 +2446,7 @@ void FixGCMC::update_gas_atoms_list()
for (int i = 0; i < nlocal; i++) {
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) {
local_gas_list[ngas_local] = i;
ngas_local++;
@ -2454,7 +2459,7 @@ void FixGCMC::update_gas_atoms_list()
} else {
for (int i = 0; i < nlocal; i++) {
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;
ngas_local++;
}

View File

@ -65,17 +65,16 @@ class FixGCMC : public Fix {
int ngcmc_type, nevery, seed;
int ncycles, nexchanges, nmcmoves;
double patomtrans, pmoltrans, pmolrotate, pmctot;
int ngas; // # of gas atoms on all procs
int ngas_local; // # of gas atoms on this proc
int ngas_before; // # of gas atoms on procs < this proc
int exchmode; // exchange ATOM or MOLECULE
int movemode; // move ATOM or MOLECULE
int regionflag; // 0 = anywhere in box, 1 = specific region
int iregion; // gcmc region
char *idregion; // gcmc region id
bool pressure_flag; // true if user specified reservoir pressure
bool charge_flag; // true if user specified atomic charge
bool full_flag; // true if doing full system energy calculations
int ngas; // # of gas atoms on all procs
int ngas_local; // # of gas atoms on this proc
int ngas_before; // # of gas atoms on procs < this proc
int exchmode; // exchange ATOM or MOLECULE
int movemode; // move ATOM or MOLECULE
class Region *region; // gcmc region
char *idregion; // gcmc region id
bool pressure_flag; // true if user specified reservoir pressure
bool charge_flag; // true if user specified atomic charge
bool full_flag; // true if doing full system energy calculations
int natoms_per_molecule; // number of atoms in each inserted molecule
int nmaxmolatoms; // number of atoms allocated for molecule arrays

View File

@ -42,21 +42,21 @@ class FixMolSwap : public Fix {
int itype, jtype;
double temperature;
int ke_flag; // 1 if kinetic energy is also swapped
double i2j_vscale; // scale factors for velocity to keep KE constant
int ke_flag; // 1 if kinetic energy is also swapped
double i2j_vscale; // scale factors for velocity to keep KE constant
double j2i_vscale;
int qflag; // 1 if charge is also swapped
double iq,jq; // charge values for all itype,jtype atoms
int qflag; // 1 if charge is also swapped
double iq, jq; // charge values for all itype,jtype atoms
bool unequal_cutoffs; // 1 if itype and jtype have any different cutoffs
tagint minmol,maxmol; // range of mol IDs selected for swaps
bool unequal_cutoffs; // 1 if itype and jtype have any different cutoffs
tagint minmol, maxmol; // range of mol IDs selected for swaps
double nswap_attempt; // cummulative stats on MC attempts and accepts
double nswap_attempt; // cummulative stats on MC attempts and accepts
double nswap_accept;
double beta; // 1/kT
double energy_stored; // energy of current state as swaps are accepted
double beta; // 1/kT
double energy_stored; // energy of current state as swaps are accepted
class RanPark *random;
class Compute *c_pe;

View File

@ -46,7 +46,6 @@
#include <cmath>
#include <cstring>
using namespace std;
using namespace LAMMPS_NS;
using namespace FixConst;
using namespace MathConst;
@ -59,8 +58,8 @@ enum{EXCHATOM,EXCHMOL}; // exchmode
FixWidom::FixWidom(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
idregion(nullptr), full_flag(false), local_gas_list(nullptr), molcoords(nullptr),
molq(nullptr), molimage(nullptr), random_equal(nullptr)
region(nullptr), idregion(nullptr), full_flag(false), local_gas_list(nullptr),
molcoords(nullptr),molq(nullptr), molimage(nullptr), random_equal(nullptr)
{
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;
time_depend = 1;
//ave_widom_chemical_potential = 0;
// required args
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_zlo = region_zhi = 0.0;
if (regionflag) {
if (domain->regions[iregion]->bboxflag == 0)
if (region) {
if (region->bboxflag == 0)
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");
region_xlo = domain->regions[iregion]->extent_xlo;
region_xhi = domain->regions[iregion]->extent_xhi;
region_ylo = domain->regions[iregion]->extent_ylo;
region_yhi = domain->regions[iregion]->extent_yhi;
region_zlo = domain->regions[iregion]->extent_zlo;
region_zhi = domain->regions[iregion]->extent_zhi;
region_xlo = region->extent_xlo;
region_xhi = region->extent_xhi;
region_ylo = region->extent_ylo;
region_yhi = region->extent_yhi;
region_zlo = region->extent_zlo;
region_zhi = region->extent_zhi;
if (region_xlo < domain->boxlo[0] || region_xhi > domain->boxhi[0] ||
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[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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++;
}
double max_region_volume = (region_xhi - region_xlo)*
(region_yhi - region_ylo)*(region_zhi - region_zlo);
double max_region_volume = (region_xhi - region_xlo) *
(region_yhi - region_ylo) * (region_zhi - region_zlo);
region_volume = max_region_volume*static_cast<double> (inside)/
static_cast<double> (attempts);
region_volume = max_region_volume * static_cast<double>(inside) / static_cast<double>(attempts);
}
// error check and further setup for exchmode = EXCHMOL
@ -191,8 +187,6 @@ void FixWidom::options(int narg, char **arg)
// defaults
exchmode = EXCHATOM;
regionflag = 0;
iregion = -1;
region_volume = 0;
max_region_attempts = 1000;
molecule_group = 0;
@ -221,11 +215,10 @@ void FixWidom::options(int narg, char **arg)
iarg += 2;
} else if (strcmp(arg[iarg],"region") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix widom command");
iregion = domain->find_region(arg[iarg+1]);
if (iregion == -1)
error->all(FLERR,"Region ID for fix widom does not exist");
region = domain->get_region_by_id(arg[iarg+1]);
if (!region)
error->all(FLERR,"Region {} for fix widom does not exist",arg[iarg+1]);
idregion = utils::strdup(arg[iarg+1]);
regionflag = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"charge") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix widom command");
@ -247,7 +240,7 @@ void FixWidom::options(int narg, char **arg)
FixWidom::~FixWidom()
{
if (regionflag) delete [] idregion;
delete[] idregion;
delete random_equal;
memory->destroy(local_gas_list);
@ -271,11 +264,18 @@ int FixWidom::setmask()
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;
ave_widom_chemical_potential = 0;
if (regionflag) volume = region_volume;
if (region) volume = region_volume;
else volume = domain->xprd * domain->yprd * domain->zprd;
// decide whether to switch to the full_energy option
@ -283,8 +283,8 @@ void FixWidom::init()
if ((force->kspace) ||
(force->pair == nullptr) ||
(force->pair->single_enable == 0) ||
(force->pair_match("hybrid",0)) ||
(force->pair_match("eam",0)) ||
(force->pair_match("^hybrid",0)) ||
(force->pair_match("^eam",0)) ||
(force->pair->tail_flag)) {
full_flag = true;
if (comm->me == 0)
@ -434,7 +434,7 @@ void FixWidom::pre_exchange()
subhi = domain->subhi;
}
if (regionflag) volume = region_volume;
if (region) volume = region_volume;
else volume = domain->xprd * domain->yprd * domain->zprd;
if (triclinic) domain->x2lamda(atom->nlocal);
@ -486,12 +486,12 @@ void FixWidom::attempt_atomic_insertion()
// pick coordinates for insertion point
if (regionflag) {
if (region) {
int region_attempt = 0;
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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++) {
if (regionflag) {
if (region) {
int region_attempt = 0;
com_coord[0] = region_xlo + random_equal->uniform() *
(region_xhi-region_xlo);
@ -570,7 +570,7 @@ void FixWidom::attempt_molecule_insertion()
(region_yhi-region_ylo);
com_coord[2] = region_zlo + random_equal->uniform() *
(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[0] = region_xlo + random_equal->uniform() *
(region_xhi-region_xlo);
@ -688,12 +688,12 @@ void FixWidom::attempt_atomic_insertion_full()
for (int imove = 0; imove < ninsertions; imove++) {
if (regionflag) {
if (region) {
int region_attempt = 0;
coord[0] = region_xlo + random_equal->uniform() * (region_xhi-region_xlo);
coord[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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[1] = region_ylo + random_equal->uniform() * (region_yhi-region_ylo);
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++) {
double com_coord[3];
if (regionflag) {
if (region) {
int region_attempt = 0;
com_coord[0] = region_xlo + random_equal->uniform() *
(region_xhi-region_xlo);
@ -809,7 +809,7 @@ void FixWidom::attempt_molecule_insertion_full()
(region_yhi-region_ylo);
com_coord[2] = region_zlo + random_equal->uniform() *
(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[0] = region_xlo + random_equal->uniform() *
(region_xhi-region_xlo);
@ -1081,7 +1081,7 @@ void FixWidom::update_gas_atoms_list()
ngas_local = 0;
if (regionflag) {
if (region) {
if (exchmode == EXCHMOL) {
@ -1114,7 +1114,7 @@ void FixWidom::update_gas_atoms_list()
for (int i = 0; i < nlocal; i++) {
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) {
local_gas_list[ngas_local] = i;
ngas_local++;
@ -1127,7 +1127,7 @@ void FixWidom::update_gas_atoms_list()
} else {
for (int i = 0; i < nlocal; i++) {
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;
ngas_local++;
}

View File

@ -53,15 +53,14 @@ class FixWidom : public Fix {
int exclusion_group, exclusion_group_bit;
int nwidom_type, nevery, seed;
int ninsertions;
int ngas; // # of gas atoms on all procs
int ngas_local; // # of gas atoms on this proc
int exchmode; // exchange ATOM or MOLECULE
int movemode; // move ATOM or MOLECULE
int regionflag; // 0 = anywhere in box, 1 = specific region
int iregion; // widom region
char *idregion; // widom region id
bool charge_flag; // true if user specified atomic charge
bool full_flag; // true if doing full system energy calculations
int ngas; // # of gas atoms on all procs
int ngas_local; // # of gas atoms on this proc
int exchmode; // exchange ATOM or MOLECULE
int movemode; // move ATOM or MOLECULE
class Region *region; // widom region
char *idregion; // widom region id
bool charge_flag; // true if user specified atomic charge
bool full_flag; // true if doing full system energy calculations
int natoms_per_molecule; // number of atoms in each inserted molecule
int nmaxmolatoms; // number of atoms allocated for molecule arrays

View File

@ -890,8 +890,8 @@ void PairMesoCNT::read_file(const char *file)
MPI_Bcast(uinf_data, uinf_points, MPI_DOUBLE, 0, world);
MPI_Bcast(gamma_data, gamma_points, MPI_DOUBLE, 0, world);
MPI_Bcast(&phi_data[0][0], phi_points*phi_points, MPI_DOUBLE, 0, world);
MPI_Bcast(&usemi_data[0][0], usemi_points*usemi_points, MPI_DOUBLE, 0, world);
MPI_Bcast(&phi_data[0][0], phi_points * phi_points, MPI_DOUBLE, 0, world);
MPI_Bcast(&usemi_data[0][0], usemi_points * usemi_points, MPI_DOUBLE, 0, world);
}
/* ----------------------------------------------------------------------

View File

@ -64,8 +64,7 @@ class PairMesoCNT : public Pair {
void sort(int *, int);
void read_file(const char *);
void read_data(PotentialFileReader &, double *, double &, double &, int);
void read_data(PotentialFileReader &, double **, double &, double &, double &, double &,
int);
void read_data(PotentialFileReader &, double **, double &, double &, double &, double &, int);
void spline_coeff(double *, double **, double, int);
void spline_coeff(double **, double ****, double, double, int);

View File

@ -57,18 +57,18 @@ class PairList : public Pair {
};
struct list_param {
int style; // potential style indicator
tagint id1, id2; // global atom ids
double cutsq; // cutoff**2 for this pair
double offset; // energy offset
union param_u param; // parameters for style
int style; // potential style indicator
tagint id1, id2; // global atom ids
double cutsq; // cutoff**2 for this pair
double offset; // energy offset
union param_u param; // parameters for style
};
protected:
double cut_global; // global cutoff distance
list_param *params; // lisf of pair interaction parameters
int npairs; // # of atom pairs in global list
int check_flag; // 1 if checking for missing pairs
double cut_global; // global cutoff distance
list_param *params; // lisf of pair interaction parameters
int npairs; // # of atom pairs in global list
int check_flag; // 1 if checking for missing pairs
};
} // namespace LAMMPS_NS

View File

@ -416,7 +416,7 @@ void MLIAPDescriptorSNAP::read_paramfile(char *paramfilename)
if ((keywd == "elems") || (keywd == "radelems") || (keywd == "welems") ||
(keywd == "rinnerelems") || (keywd == "drinnerelems")) {
if ((nelementsflag == 0) || ((int)words.count() != nelements + 1))
if ((nelementsflag == 0) || ((int) words.count() != nelements + 1))
error->all(FLERR, "Incorrect SNAP parameter file");
if (comm->me == 0) utils::logmesg(lmp, "SNAP keyword {} \n", utils::trim(line));

View File

@ -42,8 +42,8 @@ class MLIAPDescriptorSNAP : public MLIAPDescriptor {
int switchinnerflag;
double rfac0, rmin0;
double* rinnerelem;
double* drinnerelem;
double *rinnerelem;
double *drinnerelem;
};
} // namespace LAMMPS_NS

View File

@ -125,7 +125,7 @@ void MLIAPDescriptorSO3::read_paramfile(char *paramfilename)
// check for keywords with one value per element
if ((skeywd == "elems") || (skeywd == "radelems") || (skeywd == "welems")) {
if ((skeywd == "elems") || (skeywd == "radelems") || (skeywd == "welems")) {
if (nelementsflag == 0 || nwords != nelements + 1)
error->all(FLERR, "Incorrect SO3 parameter file");
@ -137,7 +137,7 @@ void MLIAPDescriptorSO3::read_paramfile(char *paramfilename)
}
elementsflag = 1;
} else if (skeywd == "radelems") {
} else if (skeywd == "radelems") {
for (int ielem = 0; ielem < nelements; ielem++) {
radelem[ielem] = utils::numeric(FLERR, skeyval, false, lmp);
if (ielem < nelements - 1) skeyval = p.next();

View File

@ -62,7 +62,9 @@ MLIAPModelPython::MLIAPModelPython(LAMMPS *lmp, char *coefffilename) :
// if LAMMPS_POTENTIALS environment variable is set, add it to PYTHONPATH as well
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);
if (coefffilename) read_coeffs(coefffilename);

Some files were not shown because too many files have changed in this diff Show More