Skip to content

Commit

Permalink
Merge pull request lammps#3971 from akohlmey/collected-small-fixes
Browse files Browse the repository at this point in the history
Collected small fixes and updates
  • Loading branch information
akohlmey authored Nov 15, 2023
2 parents 5e4761d + b326572 commit d31c3ab
Show file tree
Hide file tree
Showing 26 changed files with 445 additions and 650 deletions.
4 changes: 3 additions & 1 deletion doc/src/fix_deposit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ rotated configuration of the molecule.
existing particle. LAMMPS will issue a warning if R is smaller than
this value, based on the radii of existing and inserted particles.

.. versionadded:: TBD

The *var* and *set* keywords can be used together to provide a criterion
for accepting or rejecting the addition of an individual atom, based on its
coordinates. The *name* specified for the *var* keyword is the name of an
Expand All @@ -236,7 +238,7 @@ created atom, one for *y*, and one for *z*. When an atom is created, its
is defined. The *var* variable is then evaluated. If the returned value
is 0.0, the atom is not created. If it is non-zero, the atom is created.
For an example of how to use these keywords, see the
:doc:`create_atoms <create_atoms>`command.
:doc:`create_atoms <create_atoms>` command.

The *rate* option moves the insertion volume in the z direction (3d)
or y direction (2d). This enables particles to be inserted from a
Expand Down
96 changes: 34 additions & 62 deletions src/BOCS/fix_bocs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ const int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction
---------------------------------------------------------------------- */

FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
rfix(nullptr), id_dilate(nullptr), irregular(nullptr),
id_temp(nullptr), id_press(nullptr),
eta(nullptr), eta_dot(nullptr), eta_dotdot(nullptr),
eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr),
etap_mass(nullptr)
Fix(lmp, narg, arg), id_dilate(nullptr), irregular(nullptr), id_temp(nullptr),
id_press(nullptr), eta(nullptr), eta_dot(nullptr), eta_dotdot(nullptr), eta_mass(nullptr),
etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr), etap_mass(nullptr)
{
if (lmp->citeme) lmp->citeme->add(cite_user_bocs_package);

Expand Down Expand Up @@ -379,9 +376,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
if (deviatoric_flag) size_vector += 1;
}

nrigid = 0;
rfix = nullptr;

if (pre_exchange_flag) irregular = new Irregular(lmp);
else irregular = nullptr;

Expand Down Expand Up @@ -424,31 +418,29 @@ FixBocs::~FixBocs()
{
if (copymode) return;

delete [] id_dilate;
delete [] rfix;

delete[] id_dilate;
delete irregular;

// delete temperature and pressure if fix created them

if (tcomputeflag) modify->delete_compute(id_temp);
delete [] id_temp;
delete[] id_temp;

if (tstat_flag) {
delete [] eta;
delete [] eta_dot;
delete [] eta_dotdot;
delete [] eta_mass;
delete[] eta;
delete[] eta_dot;
delete[] eta_dotdot;
delete[] eta_mass;
}

if (pstat_flag) {
if (pcomputeflag) modify->delete_compute(id_press);
delete [] id_press;
delete[] id_press;
if (mpchain) {
delete [] etap;
delete [] etap_dot;
delete [] etap_dotdot;
delete [] etap_mass;
delete[] etap;
delete[] etap_dot;
delete[] etap_dotdot;
delete[] etap_mass;
}
}
if (p_match_coeffs) free(p_match_coeffs);
Expand Down Expand Up @@ -596,20 +588,10 @@ void FixBocs::init()
}

// detect if any rigid fixes exist so rigid bodies move when box is remapped
// rfix[] = indices to each fix rigid

delete [] rfix;
nrigid = 0;
rfix = nullptr;

for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->rigid_flag) nrigid++;
if (nrigid) {
rfix = new int[nrigid];
nrigid = 0;
for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->rigid_flag) rfix[nrigid++] = i;
}
rfix.clear();
for (auto &ifix : modify->get_fix_list())
if (ifix->rigid_flag) rfix.push_back(ifix);
}

// NJD MRD 2 functions
Expand Down Expand Up @@ -1204,9 +1186,7 @@ void FixBocs::remap()
domain->x2lamda(x[i],x[i]);
}

if (nrigid)
for (i = 0; i < nrigid; i++)
modify->fix[rfix[i]]->deform(0);
for (auto &ifix : rfix) ifix->deform(0);

// reset global and local box to new size/shape

Expand Down Expand Up @@ -1351,9 +1331,7 @@ void FixBocs::remap()
domain->lamda2x(x[i],x[i]);
}

if (nrigid)
for (i = 0; i < nrigid; i++)
modify->fix[rfix[i]]->deform(1);
for (auto &ifix : rfix) ifix->deform(1);
}

/* ----------------------------------------------------------------------
Expand Down Expand Up @@ -1512,7 +1490,7 @@ int FixBocs::modify_param(int narg, char **arg)
modify->delete_compute(id_temp);
tcomputeflag = 0;
}
delete [] id_temp;
delete[] id_temp;
id_temp = utils::strdup(arg[1]);

int icompute = modify->find_compute(arg[1]);
Expand Down Expand Up @@ -1544,30 +1522,24 @@ int FixBocs::modify_param(int narg, char **arg)
modify->delete_compute(id_press);
pcomputeflag = 0;
}
delete [] id_press;
delete[] id_press;
id_press = utils::strdup(arg[1]);

int icompute = modify->find_compute(arg[1]);
if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID");
pressure = modify->compute[icompute];

if (p_match_flag) // NJD MRD
{
if (p_basis_type == BASIS_ANALYTIC)
{
(dynamic_cast<ComputePressureBocs *>(pressure))->send_cg_info(p_basis_type, N_p_match,
p_match_coeffs, N_mol, vavg);
}
else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE )
{
(dynamic_cast<ComputePressureBocs *>(pressure))->send_cg_info(p_basis_type, splines, spline_length );
pressure = modify->get_compute_by_id(id_press);
if (!pressure) error->all(FLERR,"Could not find fix_modify pressure ID {}", id_press);
if (!pressure->pressflag)
error->all(FLERR, "Fix_modify pressure ID {} does not compute pressure", id_press);

if (p_match_flag) {
auto bocspress = dynamic_cast<ComputePressureBocs *>(pressure);
if (bocspress) {
if (p_basis_type == BASIS_ANALYTIC) {
bocspress->send_cg_info(p_basis_type, N_p_match, p_match_coeffs, N_mol, vavg);
} else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE) {
bocspress->send_cg_info(p_basis_type, splines, spline_length);
}
}
}

if (pressure->pressflag == 0)
{
error->all(FLERR, "Fix_modify pressure ID does not compute pressure");
}
return 2;
}

Expand Down
3 changes: 1 addition & 2 deletions src/BOCS/fix_bocs.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ class FixBocs : public Fix {
double drag, tdrag_factor; // drag factor on particle thermostat
double pdrag_factor; // drag factor on barostat
int kspace_flag; // 1 if KSpace invoked, 0 if not
int nrigid; // number of rigid fixes
int dilate_group_bit; // mask for dilation group
int *rfix; // indices of rigid fixes
std::vector<Fix *> rfix; // list of rigid fixes
char *id_dilate; // group name to dilate
class Irregular *irregular; // for migrating atoms after box flips

Expand Down
Loading

0 comments on commit d31c3ab

Please sign in to comment.