Skip to content

Commit

Permalink
Merge pull request lammps#4422 from akohlmey/collected-small-changes
Browse files Browse the repository at this point in the history
Collected small changes and fixes
  • Loading branch information
akohlmey authored Dec 24, 2024
2 parents aeb2190 + fbba20f commit f00addc
Show file tree
Hide file tree
Showing 24 changed files with 223 additions and 142 deletions.
2 changes: 2 additions & 0 deletions cmake/Modules/Packages/VTK.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# FindVTK requires that C support is enabled when looking for MPI support
enable_language(C)
find_package(VTK REQUIRED NO_MODULE)
target_compile_definitions(lammps PRIVATE -DLAMMPS_VTK)
if (VTK_MAJOR_VERSION VERSION_LESS 9.0)
Expand Down
2 changes: 1 addition & 1 deletion doc/src/Build_extras.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ option in preparations to run on Aurora system at Argonne.
.. code:: bash
# CUDA target (not recommended, use GPU_ARCH=cuda)
# CUDA target (not recommended, use GPU_API=cuda)
# !!! DO NOT set CMAKE_CXX_COMPILER !!!
export HIP_PLATFORM=nvcc
export HIP_PATH=/path/to/HIP/install
Expand Down
46 changes: 21 additions & 25 deletions src/BOCS/fix_bocs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,37 +466,33 @@ void FixBocs::init()

// set temperature and pressure ptrs
temperature = modify->get_compute_by_id(id_temp);
if (!temperature)
error->all(FLERR,"Temperature compute ID {} for fix bocs does not exist", id_temp);

if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
if (!temperature) {
error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style);
} else {
if (temperature->tempflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute a temperature", id_temp, style);
if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
}

if (pstat_flag) {
pressure = modify->get_compute_by_id(id_press);
if (!pressure)
error->all(FLERR,"Pressure compute ID {} for fix bocs does not exist", id_press);
error->all(FLERR,"Pressure compute ID {} for fix {} does not exist", id_press, style);
if (pressure->pressflag == 0)
error->all(FLERR,"Compute ID {} for fix {} does not compute pressure", id_press, style);
}


if (pstat_flag)
{
if (p_match_flag) // MRD NJD
{
if (pstat_flag) {
if (p_match_flag) { // MRD NJD
auto pressure_bocs = dynamic_cast<ComputePressureBocs *>(pressure);
if (pressure_bocs)
{
if (p_basis_type == BASIS_ANALYTIC)
{
if (pressure_bocs) {
if (p_basis_type == BASIS_ANALYTIC) {
pressure_bocs->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)
{
} else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE) {
pressure_bocs->send_cg_info(p_basis_type, splines, spline_length);
}
}
else
{
} else {
error->all(FLERR,"Unable to find compatible pressure compute");
}
}
Expand Down Expand Up @@ -656,8 +652,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
if (numBadVolumeIntervals > 0 && comm->me == 0) {
error->message(FLERR, "INFO: total number bad volume intervals = {}", numBadVolumeIntervals);
}
}
else {
} else {
error->all(FLERR,"ERROR: Unable to open file: {}", filename);
}

Expand Down Expand Up @@ -955,8 +950,9 @@ void FixBocs::final_integrate()
tdof = temperature->dof;

if (pstat_flag) {
if (pstyle == ISO) pressure->compute_scalar();
else {
if (pstyle == ISO) {
pressure->compute_scalar();
} else {
temperature->compute_vector();
pressure->compute_vector();
}
Expand Down
24 changes: 12 additions & 12 deletions src/DRUDE/fix_langevin_drude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ FixLangevinDrude::FixLangevinDrude(LAMMPS *lmp, int narg, char **arg) :
FixLangevinDrude::~FixLangevinDrude()
{
delete random_core;
delete [] tstr_core;
delete[] tstr_core;
delete random_drude;
delete [] tstr_drude;
delete[] tstr_drude;
}

/* ---------------------------------------------------------------------- */
Expand Down Expand Up @@ -144,22 +144,22 @@ void FixLangevinDrude::init()
else error->all(FLERR,"Variable for fix langevin/drude is invalid style");
}

int ifix;
for (ifix = 0; ifix < modify->nfix; ifix++)
if (strcmp(modify->fix[ifix]->style,"drude") == 0) break;
if (ifix == modify->nfix) error->all(FLERR, "fix langevin/drude requires fix drude");
fix_drude = dynamic_cast<FixDrude *>(modify->fix[ifix]);
auto fdrude = modify->get_fix_by_style("^drude$");
if (fdrude.size() < 1) error->all(FLERR, "Fix {} requires fix drude", style);
if (fdrude.size() > 1) error->all(FLERR, "There must be only one fix drude");
fix_drude = dynamic_cast<FixDrude *>(fdrude[0]);
if (!fix_drude) error->all(FLERR, "Fix {} requires fix drude", style);

if (!utils::strmatch(update->integrate_style,"^verlet"))
error->all(FLERR,"Run style respa is not compatible with fix langevin/drude");
if (!comm->ghost_velocity)
error->all(FLERR,"fix langevin/drude requires ghost velocities. Use comm_modify vel yes");
}

/* ---------------------------------------------------------------------- */

void FixLangevinDrude::setup(int /*vflag*/)
{
if (!utils::strmatch(update->integrate_style,"^verlet"))
error->all(FLERR,"RESPA style not compatible with fix langevin/drude");
if (!comm->ghost_velocity)
error->all(FLERR,"fix langevin/drude requires ghost velocities. Use comm_modify vel yes");

if (zero) {
int *mask = atom->mask;
int nlocal = atom->nlocal;
Expand Down
14 changes: 10 additions & 4 deletions src/DRUDE/fix_tgnh_drude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,20 @@ void FixTGNHDrude::init()
// set temperature and pressure ptrs

temperature = modify->get_compute_by_id(id_temp);
if (!temperature) error->all(FLERR,"Temperature ID for fix {} does not exist", style);

if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
if (!temperature) {
error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style);
} else {
if (temperature->tempflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute a temperature", id_temp, style);
if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
}

if (pstat_flag) {
pressure = modify->get_compute_by_id(id_press);
if (!pressure) error->all(FLERR,"Pressure ID for fix {} does not exist", id_press);
if (pressure->pressflag == 0)
error->all(FLERR,"Compute ID {} does not compute pressure", id_press);
}

// set timesteps and frequencies
Expand Down
16 changes: 9 additions & 7 deletions src/EFF/fix_temp_rescale_eff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ int FixTempRescaleEff::setmask()

void FixTempRescaleEff::init()
{
int icompute = modify->find_compute(id_temp);
if (icompute < 0)
error->all(FLERR,"Temperature ID for fix temp/rescale/eff does not exist");
temperature = modify->compute[icompute];

if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
temperature = modify->get_compute_by_id(id_temp);
if (!temperature) {
error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style);
} else {
if (temperature->tempflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute a temperature", id_temp, style);
if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
}
}

/* ---------------------------------------------------------------------- */
Expand Down
7 changes: 5 additions & 2 deletions src/EXTRA-FIX/fix_deform_pressure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,14 @@ void FixDeformPressure::init()
if (pressure_flag) {
temperature = modify->get_compute_by_id(id_temp);
if (!temperature)
error->all(FLERR, "Temperature ID {} for fix deform/pressure does not exist", id_temp);
error->all(FLERR, "Temperature compute ID {} for fix deform/pressure does not exist",
id_temp);

pressure = modify->get_compute_by_id(id_press);
if (!pressure)
error->all(FLERR, "Pressure ID {} for fix deform/pressure does not exist", id_press);
error->all(FLERR, "Pressure compute ID {} for fix deform/pressure does not exist", id_press);
if (pressure->pressflag == 0)
error->all(FLERR,"Compute ID {} does not compute pressure", id_press);
}

// if yz [3] changes and will cause box flip, then xy [5] cannot be changing
Expand Down
15 changes: 10 additions & 5 deletions src/EXTRA-FIX/fix_npt_cauchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,15 +653,20 @@ void FixNPTCauchy::init()
// set temperature and pressure ptrs

temperature = modify->get_compute_by_id(id_temp);
if (!temperature)
error->all(FLERR,"Temperature ID {} for fix npt/cauchy does not exist", id_temp);

if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
if (!temperature) {
error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style);
} else {
if (temperature->tempflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute a temperature", id_temp, style);
if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
}

if (pstat_flag) {
pressure = modify->get_compute_by_id(id_press);
if (!pressure) error->all(FLERR,"Pressure ID {} for fix npt/cauchy does not exist", id_press);
if (pressure->pressflag == 0)
error->all(FLERR,"Compute ID {} does not compute pressure", id_press);
}

// set timesteps and frequencies
Expand Down
23 changes: 13 additions & 10 deletions src/EXTRA-FIX/fix_temp_csld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,23 @@ void FixTempCSLD::init()
if (tstr) {
tvar = input->variable->find(tstr);
if (tvar < 0)
error->all(FLERR,"Variable name {} for fix temp/csld does not exist", tstr);
error->all(FLERR,"Variable name {} for fix {} does not exist", tstr, style);
if (input->variable->equalstyle(tvar)) tstyle = EQUAL;
else error->all(FLERR,"Variable {} for fix temp/csld is invalid style", tstr);
else error->all(FLERR,"Variable {} for fix {} is invalid style", tstr, style);
}

temperature = modify->get_compute_by_id(id_temp);
if (!temperature)
error->all(FLERR,"Temperature ID {} for fix temp/csld does not exist", id_temp);

if (modify->check_rigid_group_overlap(groupbit))
error->warning(FLERR,"Cannot thermostat atoms in rigid bodies");
if (!temperature) {
error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style);
} else {
if (temperature->tempflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute a temperature", id_temp, style);
if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
}

if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
if ((modify->check_rigid_group_overlap(groupbit)) && (comm->me == 0))
error->warning(FLERR,"Cannot thermostat atoms in rigid bodies with fix {}", style);
}

/* ---------------------------------------------------------------------- */
Expand All @@ -170,7 +173,7 @@ void FixTempCSLD::end_of_step()
modify->clearstep_compute();
t_target = input->variable->compute_equal(tvar);
if (t_target < 0.0)
error->one(FLERR, "Fix temp/csld variable returned negative temperature");
error->one(FLERR, "Fix {} variable returned negative temperature", style);
modify->addstep_compute(update->ntimestep + nevery);
}

Expand Down
29 changes: 18 additions & 11 deletions src/EXTRA-FIX/fix_temp_csvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ FixTempCSVR::FixTempCSVR(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
tstr(nullptr), id_temp(nullptr), random(nullptr)
{
if (narg != 7) error->all(FLERR,"Illegal fix temp/csvr command");
if (narg != 7) error->all(FLERR,"Incorrect number of arguments for fix {} command", style);

// CSVR thermostat should be applied every step

Expand Down Expand Up @@ -75,16 +75,16 @@ FixTempCSVR::FixTempCSVR(LAMMPS *lmp, int narg, char **arg) :

// error checks

if (t_period <= 0.0) error->all(FLERR,"Illegal fix temp/csvr command");
if (seed <= 0) error->all(FLERR,"Illegal fix temp/csvr command");
if (t_period <= 0.0) error->all(FLERR,"Illegal fix {} command period value", style);
if (seed <= 0) error->all(FLERR,"Illegal fix {} command seed value", style);

random = new RanMars(lmp,seed + comm->me);

// create a new compute temp style
// id = fix-ID + temp, compute group = fix group

id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
modify->add_compute(fmt::format("{} {} temp", id_temp, group->names[igroup]));
tflag = 1;

nmax = -1;
Expand Down Expand Up @@ -124,17 +124,23 @@ void FixTempCSVR::init()
if (tstr) {
tvar = input->variable->find(tstr);
if (tvar < 0)
error->all(FLERR,"Variable name {} for fix temp/csvr does not exist", tstr);
error->all(FLERR,"Variable name {} for fix {} does not exist", tstr, style);
if (input->variable->equalstyle(tvar)) tstyle = EQUAL;
else error->all(FLERR,"Variable {} for fix temp/csvr is invalid style", tstr);
else error->all(FLERR,"Variable {} for fix {} is invalid style", tstr, style);
}

temperature = modify->get_compute_by_id(id_temp);
if (!temperature)
error->all(FLERR,"Temperature ID {} for fix temp/csvr does not exist", id_temp);
if (!temperature) {
error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style);
} else {
if (temperature->tempflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute a temperature", id_temp, style);
if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
}

if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
if ((modify->check_rigid_group_overlap(groupbit)) && (comm->me == 0))
error->warning(FLERR,"Cannot thermostat atoms in rigid bodies with fix {}", style);
}

/* ---------------------------------------------------------------------- */
Expand All @@ -153,7 +159,8 @@ void FixTempCSVR::end_of_step()
modify->clearstep_compute();
t_target = input->variable->compute_equal(tvar);
if (t_target < 0.0)
error->one(FLERR, "Fix temp/csvr variable returned negative temperature");
error->one(FLERR, "Fix {} variable {} returned negative temperature",
style, input->variable->names[tvar]);
modify->addstep_compute(update->ntimestep + nevery);
}

Expand Down
16 changes: 8 additions & 8 deletions src/MANIFOLD/fix_nvt_manifold_rattle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ void FixNVTManifoldRattle::init()
// Makes sure the manifold params are set initially.
update_var_params();

int icompute = modify->find_compute(id_temp);
if (icompute < 0) {
error->all(FLERR,"Temperature ID for fix nvt/manifold/rattle "
"does not exist");
temperature = modify->get_compute_by_id(id_temp);
if (!temperature) {
error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style);
} else {
if (temperature->tempflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute a temperature", id_temp, style);
if (temperature->tempbias) which = BIAS;
else which = NOBIAS;
}
temperature = modify->compute[icompute];
if (temperature->tempbias) which = BIAS;
else which = NOBIAS;

}

void FixNVTManifoldRattle::setup(int /*vflag*/)
Expand Down
16 changes: 9 additions & 7 deletions src/MC/fix_bond_swap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@ void FixBondSwap::init()
// require an atom style with molecule IDs

if (atom->molecule == nullptr)
error->all(FLERR,
"Must use atom style with molecule IDs with fix bond/swap");
error->all(FLERR, "Must use atom style with molecule IDs with fix bond/swap");

int icompute = modify->find_compute(id_temp);
if (icompute < 0)
error->all(FLERR,"Temperature ID for fix bond/swap does not exist");
temperature = modify->compute[icompute];
temperature = modify->get_compute_by_id(id_temp);
if (!temperature) {
error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style);
} else {
if (temperature->tempflag == 0)
error->all(FLERR, "Compute ID {} for fix {} does not compute a temperature", id_temp, style);
}

// pair and bonds must be defined
// no dihedral or improper potentials allowed
Expand All @@ -159,7 +161,7 @@ void FixBondSwap::init()
"topology because no angle_style is defined");

if (force->dihedral || force->improper)
error->all(FLERR,"Fix bond/swap cannot use dihedral or improper styles");
error->all(FLERR,"Fix bond/swap cannot be used with dihedral or improper styles");

if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 ||
force->special_lj[3] != 1.0)
Expand Down
Loading

0 comments on commit f00addc

Please sign in to comment.