diff --git a/cmake/Modules/Packages/VTK.cmake b/cmake/Modules/Packages/VTK.cmake index a0de1e0ff46..48b1cdba112 100644 --- a/cmake/Modules/Packages/VTK.cmake +++ b/cmake/Modules/Packages/VTK.cmake @@ -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) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 8465bea8290..a278b393c54 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -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 diff --git a/src/BOCS/fix_bocs.cpp b/src/BOCS/fix_bocs.cpp index 25471d04a48..0c4d6a41ad8 100644 --- a/src/BOCS/fix_bocs.cpp +++ b/src/BOCS/fix_bocs.cpp @@ -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(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"); } } @@ -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); } @@ -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(); } diff --git a/src/DRUDE/fix_langevin_drude.cpp b/src/DRUDE/fix_langevin_drude.cpp index 1b165c029aa..c67c729c7c1 100644 --- a/src/DRUDE/fix_langevin_drude.cpp +++ b/src/DRUDE/fix_langevin_drude.cpp @@ -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; } /* ---------------------------------------------------------------------- */ @@ -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(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(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; diff --git a/src/DRUDE/fix_tgnh_drude.cpp b/src/DRUDE/fix_tgnh_drude.cpp index e15e865ce8c..bb0640fa45e 100644 --- a/src/DRUDE/fix_tgnh_drude.cpp +++ b/src/DRUDE/fix_tgnh_drude.cpp @@ -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 diff --git a/src/EFF/fix_temp_rescale_eff.cpp b/src/EFF/fix_temp_rescale_eff.cpp index 5970c6cba73..0ca9c3e6e56 100644 --- a/src/EFF/fix_temp_rescale_eff.cpp +++ b/src/EFF/fix_temp_rescale_eff.cpp @@ -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; + } } /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-FIX/fix_deform_pressure.cpp b/src/EXTRA-FIX/fix_deform_pressure.cpp index a5b7b1fcb15..6d8bfbbe934 100644 --- a/src/EXTRA-FIX/fix_deform_pressure.cpp +++ b/src/EXTRA-FIX/fix_deform_pressure.cpp @@ -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 diff --git a/src/EXTRA-FIX/fix_npt_cauchy.cpp b/src/EXTRA-FIX/fix_npt_cauchy.cpp index 8eb6a80b6de..123cd6ca0a6 100644 --- a/src/EXTRA-FIX/fix_npt_cauchy.cpp +++ b/src/EXTRA-FIX/fix_npt_cauchy.cpp @@ -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 diff --git a/src/EXTRA-FIX/fix_temp_csld.cpp b/src/EXTRA-FIX/fix_temp_csld.cpp index 13ead5b3938..f60835ff394 100644 --- a/src/EXTRA-FIX/fix_temp_csld.cpp +++ b/src/EXTRA-FIX/fix_temp_csld.cpp @@ -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); } /* ---------------------------------------------------------------------- */ @@ -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); } diff --git a/src/EXTRA-FIX/fix_temp_csvr.cpp b/src/EXTRA-FIX/fix_temp_csvr.cpp index 6b46629a997..9aeb51cfd8b 100644 --- a/src/EXTRA-FIX/fix_temp_csvr.cpp +++ b/src/EXTRA-FIX/fix_temp_csvr.cpp @@ -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 @@ -75,8 +75,8 @@ 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); @@ -84,7 +84,7 @@ FixTempCSVR::FixTempCSVR(LAMMPS *lmp, int narg, char **arg) : // 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; @@ -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); } /* ---------------------------------------------------------------------- */ @@ -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); } diff --git a/src/MANIFOLD/fix_nvt_manifold_rattle.cpp b/src/MANIFOLD/fix_nvt_manifold_rattle.cpp index d8b91fdda1a..c73438a7ef3 100644 --- a/src/MANIFOLD/fix_nvt_manifold_rattle.cpp +++ b/src/MANIFOLD/fix_nvt_manifold_rattle.cpp @@ -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*/) diff --git a/src/MC/fix_bond_swap.cpp b/src/MC/fix_bond_swap.cpp index cc67a07ed2f..ff90b816957 100644 --- a/src/MC/fix_bond_swap.cpp +++ b/src/MC/fix_bond_swap.cpp @@ -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 @@ -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) diff --git a/src/PLUMED/fix_plumed.cpp b/src/PLUMED/fix_plumed.cpp index ec23e42ddb3..f88c0dce18f 100644 --- a/src/PLUMED/fix_plumed.cpp +++ b/src/PLUMED/fix_plumed.cpp @@ -272,6 +272,19 @@ void FixPlumed::init() // in a setup method for (int i = 0; i < 6; i++) virial[i] = 0.; + + c_pe = modify->get_compute_by_id(id_pe); + if (!c_pe) { + error->all(FLERR,"Potential energy compute ID {} for fix plumed does not exist", id_pe); + if (c_pe->peflag == 0) + error->all(FLERR,"Compute ID {} does not compute potential energy", id_pe); + } + + if (!c_press) { + error->all(FLERR,"Pressure compute ID {} for fix plumed does not exist", id_press); + if (c_press->pressflag == 0) + error->all(FLERR,"Compute ID {} does not compute pressure", id_press); + } } void FixPlumed::setup(int vflag) diff --git a/src/REPLICA/fix_grem.cpp b/src/REPLICA/fix_grem.cpp index 4571afdcbac..859c5f1bb31 100644 --- a/src/REPLICA/fix_grem.cpp +++ b/src/REPLICA/fix_grem.cpp @@ -117,11 +117,11 @@ FixGrem::~FixGrem() modify->delete_compute(id_press); modify->delete_compute(id_ke); modify->delete_compute(id_pe); - delete [] id_temp; - delete [] id_press; - delete [] id_ke; - delete [] id_pe; - delete [] id_nh; + delete[] id_temp; + delete[] id_press; + delete[] id_ke; + delete[] id_pe; + delete[] id_nh; } /* ---------------------------------------------------------------------- */ diff --git a/src/RIGID/fix_rigid_nh.cpp b/src/RIGID/fix_rigid_nh.cpp index f628b639abe..9c51c0e3d21 100644 --- a/src/RIGID/fix_rigid_nh.cpp +++ b/src/RIGID/fix_rigid_nh.cpp @@ -247,7 +247,7 @@ void FixRigidNH::init() if (tcomputeflag) { temperature = modify->get_compute_by_id(id_temp); if (!temperature) - error->all(FLERR,"Temperature ID {} for fix {} does not exist", id_temp, style); + error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style); } if (pstat_flag) { @@ -285,6 +285,8 @@ void FixRigidNH::init() pressure = modify->get_compute_by_id(id_press); if (!pressure) error->all(FLERR,"Pressure ID {} for fix {} does not exist", id_press, style); + if (pressure->pressflag == 0) + error->all(FLERR,"Compute ID {} does not compute pressure", id_press); // detect if any rigid fixes exist so rigid bodies move on remap // this will include self diff --git a/src/RIGID/fix_rigid_nh_small.cpp b/src/RIGID/fix_rigid_nh_small.cpp index 3ee11e28d25..984f60e1f61 100644 --- a/src/RIGID/fix_rigid_nh_small.cpp +++ b/src/RIGID/fix_rigid_nh_small.cpp @@ -222,7 +222,7 @@ void FixRigidNHSmall::init() if (tcomputeflag) { temperature = modify->get_compute_by_id(id_temp); if (!temperature) - error->all(FLERR,"Temperature ID {} for fix {} does not exist", id_temp, style); + error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style); } if (pstat_flag) { @@ -237,7 +237,8 @@ void FixRigidNHSmall::init() int *dimflag = deform->dimflag; if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || (p_flag[2] && dimflag[2])) - error->all(FLERR,"Cannot use fix {} and fix deform on same component of stress tensor", style); + error->all(FLERR,"Cannot use fix {} and fix deform on same component of stress tensor", + style); } } @@ -260,6 +261,8 @@ void FixRigidNHSmall::init() pressure = modify->get_compute_by_id(id_press); if (!pressure) error->all(FLERR,"Pressure ID {} for fix {} does not exist", id_press, style); + if (pressure->pressflag == 0) + error->all(FLERR,"Compute ID {} does not compute pressure", id_press); // detect if any rigid fixes exist so rigid bodies move on remap // this will include self diff --git a/src/fix_box_relax.cpp b/src/fix_box_relax.cpp index cf8df7cd028..1362095a286 100644 --- a/src/fix_box_relax.cpp +++ b/src/fix_box_relax.cpp @@ -348,12 +348,20 @@ void FixBoxRelax::init() // set temperature and pressure ptrs temperature = modify->get_compute_by_id(id_temp); - if (!temperature) - error->all(FLERR,"Temperature compute ID {} for fix box/relax 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); + } pressure = modify->get_compute_by_id(id_press); - if (!pressure) - error->all(FLERR,"Pressure compute ID {} for fix box/relax does not exist", id_press); + if (!pressure) { + error->all(FLERR,"Pressure compute ID {} for fix {} does not exist", id_press, style); + } else { + if (pressure->pressflag == 0) + error->all(FLERR,"Compute ID {} for fix {} does not compute pressure", id_press, style); + } pv2e = 1.0 / force->nktv2p; diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 7339ddada16..c032e73b84d 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -223,6 +223,15 @@ int FixLangevin::setmask() void FixLangevin::init() { + if (id_temp) { + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR, "Temperature compute ID {} for fix {} does not exist", id_temp, style); + + if (temperature->tempflag == 0) + error->all(FLERR, "Compute ID {} for fix {} does not compute temperature", id_temp, style); + } + if (gjfflag) { if (t_period * 2 == update->dt) error->all(FLERR, "Fix langevin gjf cannot have t_period equal to dt/2"); diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index f2ad246611f..b56033d6d6f 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -654,14 +654,21 @@ void FixNH::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", id_temp, 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, style); + if (!pressure) + 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); } // set timesteps and frequencies diff --git a/src/fix_press_berendsen.cpp b/src/fix_press_berendsen.cpp index 40dcdeeb104..c6fc0ad6026 100644 --- a/src/fix_press_berendsen.cpp +++ b/src/fix_press_berendsen.cpp @@ -266,17 +266,22 @@ void FixPressBerendsen::init() // set temperature and pressure ptrs temperature = modify->get_compute_by_id(id_temp); - if (!temperature) - error->all(FLERR, "Temperature compute ID {} for fix press/berendsen 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); + 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; + } pressure = modify->get_compute_by_id(id_press); - if (!pressure) - error->all(FLERR, "Pressure compute ID {} for fix press/berendsen does not exist", id_press); + if (!pressure) { + 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); + } // Kspace setting diff --git a/src/fix_press_langevin.cpp b/src/fix_press_langevin.cpp index 8116d66c0ae..f3c3412fbd1 100644 --- a/src/fix_press_langevin.cpp +++ b/src/fix_press_langevin.cpp @@ -421,8 +421,11 @@ void FixPressLangevin::init() // set pressure ptr pressure = modify->get_compute_by_id(id_press); - if (!pressure) + if (!pressure) { error->all(FLERR, "Pressure compute ID {} for fix press/langevin does not exist", id_press); + if (pressure->pressflag == 0) + error->all(FLERR,"Compute ID {} does not compute pressure", id_press); + } // Kspace setting diff --git a/src/fix_temp_berendsen.cpp b/src/fix_temp_berendsen.cpp index ea2ffeb2c03..47091259c08 100644 --- a/src/fix_temp_berendsen.cpp +++ b/src/fix_temp_berendsen.cpp @@ -117,14 +117,16 @@ void FixTempBerendsen::init() } temperature = modify->get_compute_by_id(id_temp); - if (!temperature) + if (!temperature) { error->all(FLERR,"Temperature compute ID {} for fix {} does not exist", id_temp, style); + 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 (modify->check_rigid_group_overlap(groupbit)) + if ((modify->check_rigid_group_overlap(groupbit)) && (comm->me == 0)) error->warning(FLERR,"Cannot thermostat atoms in rigid bodies with fix {}", style); - - if (temperature->tempbias) which = BIAS; - else which = NOBIAS; } /* ---------------------------------------------------------------------- */ diff --git a/src/fix_temp_rescale.cpp b/src/fix_temp_rescale.cpp index 1a8993675a9..6578463a943 100644 --- a/src/fix_temp_rescale.cpp +++ b/src/fix_temp_rescale.cpp @@ -110,17 +110,20 @@ void FixTempRescale::init() if (tstr) { tvar = input->variable->find(tstr); if (tvar < 0) - error->all(FLERR,"Variable name {} for fix temp/rescale 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/rescale 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/rescale 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; + } } /* ---------------------------------------------------------------------- */ diff --git a/unittest/commands/test_variables.cpp b/unittest/commands/test_variables.cpp index c7686cbf12d..466dac17cce 100644 --- a/unittest/commands/test_variables.cpp +++ b/unittest/commands/test_variables.cpp @@ -731,8 +731,8 @@ TEST_F(VariableTest, LabelMapMolecular) TEST_F(VariableTest, Format) { BEGIN_HIDE_OUTPUT(); - command("variable idx index -0.625"); - command("variable one equal -0.625"); + command("variable idx index -0.622"); + command("variable one equal -0.622"); command("variable two equal 1.0e-20"); command("variable three equal 1.0e10"); command("variable f1one format one \"%8.4f\""); @@ -754,25 +754,25 @@ TEST_F(VariableTest, Format) command("variable g3one format one \"%5g\""); command("variable g3two format two \"%g\""); END_HIDE_OUTPUT(); - EXPECT_THAT(variable->retrieve("one"), StrEq("-0.625")); + EXPECT_THAT(variable->retrieve("one"), StrEq("-0.622")); EXPECT_THAT(variable->retrieve("two"), StrEq("1e-20")); - EXPECT_THAT(variable->retrieve("f1one"), StrEq(" -0.6250")); + EXPECT_THAT(variable->retrieve("f1one"), StrEq(" -0.6220")); EXPECT_THAT(variable->retrieve("f1two"), StrEq(" 0.0000")); EXPECT_THAT(variable->retrieve("f2one"), StrEq("-0.62")); EXPECT_THAT(variable->retrieve("f2two"), StrEq(" 0.0000000000000000000100000")); - EXPECT_THAT(variable->retrieve("f3one"), StrEq("-0.625000")); + EXPECT_THAT(variable->retrieve("f3one"), StrEq("-0.622000")); EXPECT_THAT(variable->retrieve("f3two"), StrEq("0.000000")); - EXPECT_THAT(variable->retrieve("e1one"), StrEq(" -6.2500e-01")); + EXPECT_THAT(variable->retrieve("e1one"), StrEq(" -6.2200e-01")); EXPECT_THAT(variable->retrieve("e1two"), StrEq("1.0000e-20 ")); - EXPECT_THAT(variable->retrieve("e2one"), StrEq("-6.25E-01")); + EXPECT_THAT(variable->retrieve("e2one"), StrEq("-6.22E-01")); EXPECT_THAT(variable->retrieve("e2two"), StrEq(" 9.999999999999999E-21")); - EXPECT_THAT(variable->retrieve("e3one"), StrEq("-6.250000e-01")); + EXPECT_THAT(variable->retrieve("e3one"), StrEq("-6.220000e-01")); EXPECT_THAT(variable->retrieve("e3two"), StrEq("1.000000e-20")); - EXPECT_THAT(variable->retrieve("g1one"), StrEq(" -0.625")); + EXPECT_THAT(variable->retrieve("g1one"), StrEq(" -0.622")); EXPECT_THAT(variable->retrieve("g1two"), StrEq("1e-20 ")); EXPECT_THAT(variable->retrieve("g2one"), StrEq("-0.62")); EXPECT_THAT(variable->retrieve("g2two"), StrEq(" 1E-20")); - EXPECT_THAT(variable->retrieve("g3one"), StrEq("-0.625")); + EXPECT_THAT(variable->retrieve("g3one"), StrEq("-0.622")); EXPECT_THAT(variable->retrieve("g3two"), StrEq("1e-20")); BEGIN_HIDE_OUTPUT(); @@ -782,7 +782,7 @@ TEST_F(VariableTest, Format) command("variable f1three format three %g"); command("variable three delete"); END_HIDE_OUTPUT(); - EXPECT_THAT(variable->retrieve("f1one"), StrEq("-0.6250 ")); + EXPECT_THAT(variable->retrieve("f1one"), StrEq("-0.6220 ")); TEST_FAILURE(".*ERROR: Variable f1idx: format variable idx has incompatible style.*", command("variable f1idx format idx %8.4f"););