diff --git a/src/ELECTRODE/fix_electrode_conp.cpp b/src/ELECTRODE/fix_electrode_conp.cpp index 412a34a656..ff61eef30e 100644 --- a/src/ELECTRODE/fix_electrode_conp.cpp +++ b/src/ELECTRODE/fix_electrode_conp.cpp @@ -124,7 +124,7 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : if ((strcmp(arg[iarg], "couple") == 0)) { if (iarg + 3 > narg) error->all(FLERR, "Need two arguments after couple keyword"); int id = group->find(arg[++iarg]); - if (id < 0) error->all(FLERR, "Group does not exist"); + if (id < 0) error->all(FLERR, "Group {} does not exist", arg[iarg]); groups.push_back(id); group_bits.push_back(group->bitmask[id]); ++iarg; @@ -140,7 +140,7 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : group_psi.push_back(utils::numeric(FLERR, arg[iarg], false, lmp)); } } else if ((strcmp(arg[iarg], "algo") == 0)) { - if (!default_algo) error->one(FLERR, fmt::format("Algorithm can be set once, only")); + if (!default_algo) error->one(FLERR, "Algorithm can be set only once"); default_algo = false; if (iarg + 2 > narg) error->all(FLERR, "Need one argument after algo command"); char *algo_arg = arg[++iarg]; @@ -157,7 +157,7 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : matrix_algo = false; cg_algo = true; } else { - error->all(FLERR, "Invalid argument after algo keyword"); + error->all(FLERR, "Unknown algo keyword {}", algo_arg); } if (cg_algo) { if (iarg + 2 > narg) error->all(FLERR, "Need one argument after algo *cg command"); @@ -175,7 +175,7 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : write_vec = true; output_file_vec = arg[++iarg]; } else { - error->all(FLERR, "Illegal fix electrode/conp command with write"); + error->all(FLERR, "Illegal fix {} command with write", style); } } else if ((strncmp(arg[iarg], "read", 4) == 0)) { if (iarg + 2 > narg) error->all(FLERR, "Need one argument after read command"); @@ -186,12 +186,12 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : read_mat = true; input_file_mat = arg[++iarg]; } else { - error->all(FLERR, "Illegal fix electrode/conp command with read"); + error->all(FLERR, "Illegal fix {} command with read", style); } } else if ((strcmp(arg[iarg], "temp") == 0)) { if (iarg + 4 > narg) error->all(FLERR, "Need three arguments after temp command"); - if (strcmp(this->style, "electrode/thermo") != 0) - error->all(FLERR, "temp keyword not available for this electrode fix"); + if (!utils::strmatch(style, "electrode/thermo")) + error->all(FLERR, "temp keyword not available for fix {}", style); thermo_temp = force->boltz / force->qe2f * utils::numeric(FLERR, arg[++iarg], false, lmp); thermo_time = utils::numeric(FLERR, arg[++iarg], false, lmp); thermo_init = utils::inumeric(FLERR, arg[++iarg], false, lmp); @@ -203,7 +203,7 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : } else if ((strcmp(arg[iarg], "ffield") == 0)) { ffield = utils::logical(FLERR, arg[++iarg], false, lmp); } else { - error->all(FLERR, "Illegal fix electrode/conp command"); + error->all(FLERR, "Unknown keyword {} for fix {} command", arg[iarg], style); } iarg++; } @@ -241,9 +241,7 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : } if (read_inv && read_mat) error->all(FLERR, "Cannot read matrix from two files"); if (write_mat && read_inv) - error->all(FLERR, - "Cannot write elastance matrix if reading capacitance matrix " - "from file"); + error->all(FLERR, "Cannot write elastance matrix if reading capacitance matrix from file"); num_of_groups = static_cast(groups.size()); size_vector = num_of_groups; array_flag = !!(algo == Algo::MATRIX_INV); @@ -291,7 +289,7 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : int FixElectrodeConp::modify_param(int narg, char **arg) { if (strcmp(arg[0], "tf") == 0) { - if (narg < 4) error->all(FLERR, fmt::format("Incorrect number of arguments for fix_modify tf")); + if (narg < 4) error->all(FLERR, "Incorrect number of arguments for fix_modify {}", style); tfflag = true; // read atom type, Thomas-Fermi length, and voronoi volume (reciprocal // number density) @@ -323,13 +321,12 @@ int FixElectrodeConp::modify_param(int narg, char **arg) return 4; } else if (strcmp(arg[0], "timer") == 0) { - if (narg < 2) - error->all(FLERR, fmt::format("Incorrect number of arguments for fix_modify timer")); + if (narg < 2) error->all(FLERR, "Incorrect number of arguments for fix_modify {} timer", style); timer_flag = utils::logical(FLERR, arg[1], false, lmp); return 2; } else - error->all(FLERR, "Invalid argument for fix_modify electrode"); + error->all(FLERR, "Unknown argument {} for fix_modify {}", arg[0], style); return 0; } @@ -351,11 +348,11 @@ int FixElectrodeConp::modify_param(const std::string ¶m_str) int FixElectrodeConp::groupnum_from_name(char *groupname) { int id = group->find(groupname); - if (id < 0) error->all(FLERR, fmt::format("Group {} does not exist", groupname)); + if (id < 0) error->all(FLERR, "Group {} does not exist", groupname); for (int g = 0; g < num_of_groups; g++) { if (groups[g] == id) return g; } - error->all(FLERR, fmt::format("Group {} is not coupled by fix electrode", groupname)); + error->all(FLERR, "Group {} is not coupled by fix electrode", groupname); return -1; // dummy return value } @@ -445,7 +442,7 @@ void FixElectrodeConp::setup_post_neighbor() } MPI_Allreduce(MPI_IN_PLACE, &unset_tf, 1, MPI_INT, MPI_SUM, world); if (unset_tf) - error->all(FLERR, fmt::format("Thomas-Fermi parameters not set for all types in electrode")); + error->all(FLERR, "Thomas-Fermi parameters not set for all types in fix {}", style); } // get equal-style variable ids: @@ -454,11 +451,9 @@ void FixElectrodeConp::setup_post_neighbor() if (group_psi_var_styles[g] == VarStyle::CONST) continue; const char *var_name = group_psi_var_names[g].c_str(); int var_id = input->variable->find(var_name); - if (var_id < 0) - error->all(FLERR, fmt::format("Variable '{}' for fix electrode does not exist", var_name)); + if (var_id < 0) error->all(FLERR, "Variable '{}' for fix {} does not exist", var_name, style); if (!input->variable->equalstyle(var_id)) - error->all(FLERR, - fmt::format("Variable '{}' for fix electrode is not equal-style", var_name)); + error->all(FLERR, "Variable '{}' for fix {} is not equal-style", var_name, style); group_psi_var_ids[g] = var_id; } @@ -508,9 +503,8 @@ void FixElectrodeConp::setup_post_neighbor() if (comm->me == 0 && write_mat) { auto f_mat = fopen(output_file_mat.c_str(), "w"); if (f_mat == nullptr) - error->one(FLERR, - fmt::format("Cannot open elastance matrix file {}: {}", output_file_mat, - utils::getsyserror())); + error->one(FLERR, "Cannot open elastance matrix file {}: {}", output_file_mat, + utils::getsyserror()); write_to_file(f_mat, taglist_bygroup, order_matrix(group_idx, elastance)); fclose(f_mat); } @@ -534,8 +528,7 @@ void FixElectrodeConp::setup_post_neighbor() compute_macro_matrices(); MPI_Barrier(world); if (timer_flag && (comm->me == 0)) - utils::logmesg( - lmp, fmt::format("SD-vector and macro matrices time: {:.4g} s\n", MPI_Wtime() - start)); + utils::logmesg(lmp, "SD-vector and macro matrices time: {:.4g} s\n", MPI_Wtime() - start); } } // initial charges and b vector @@ -550,11 +543,9 @@ void FixElectrodeConp::setup_post_neighbor() if (comm->me == 0) { auto f_vec = fopen(output_file_vec.c_str(), "w"); if (f_vec == nullptr) - error->one( - FLERR, - fmt::format("Cannot open vector file {}: {}", output_file_vec, utils::getsyserror())); + error->one(FLERR, "Cannot open vector file {}: {}", output_file_vec, utils::getsyserror()); std::vector> vec(ngroup, std::vector(1)); - for (int i = 0; i < ngroup; i++) { vec[group_idx[i]][0] = potential_iele[i]; } + for (int i = 0; i < ngroup; i++) vec[group_idx[i]][0] = potential_iele[i]; write_to_file(f_vec, taglist_bygroup, vec); fclose(f_vec); } @@ -564,9 +555,8 @@ void FixElectrodeConp::setup_post_neighbor() if (comm->me == 0) { auto f_inv = fopen(output_file_inv.c_str(), "w"); if (f_inv == nullptr) - error->one(FLERR, - fmt::format("Cannot open capacitance matrix file {}: {}", output_file_inv, - utils::getsyserror())); + error->one(FLERR, "Cannot open capacitance matrix file {}: {}", output_file_inv, + utils::getsyserror()); write_to_file(f_inv, taglist_bygroup, order_matrix(group_idx, capacitance)); fclose(f_inv); } @@ -603,7 +593,7 @@ void FixElectrodeConp::invert() if (info_rf != 0 || info_ri != 0) error->all(FLERR, "CONP matrix inversion failed!"); MPI_Barrier(world); if (timer_flag && (comm->me == 0)) - utils::logmesg(lmp, fmt::format("Invert time: {:.4g} s\n", MPI_Wtime() - invert_time)); + utils::logmesg(lmp, "Invert time: {:.4g} s\n", MPI_Wtime() - invert_time); } /* ---------------------------------------------------------------------- */ @@ -694,9 +684,9 @@ void FixElectrodeConp::setup_pre_exchange() // create_taglist mem_needed /= (1024 * 1024 * 1024); // convert to GiB if (mem_needed > 0.5 && comm->me == 0) error->warning(FLERR, - fmt::format("Please ensure there is sufficient memory for fix electrode " - "(anticipated usage is at least {:.1f} GiB per proc)", - mem_needed)); + "Please ensure there is sufficient memory for fix electrode " + "(anticipated usage is at least {:.1f} GiB per proc)", + mem_needed); } /* ---------------------------------------------------------------------- */ @@ -867,7 +857,7 @@ void FixElectrodeConp::update_charges() update_time += MPI_Wtime() - start; } -std::vector FixElectrodeConp::ele_ele_interaction(const std::vector& q_local) +std::vector FixElectrodeConp::ele_ele_interaction(const std::vector &q_local) { assert(q_local.size() == nlocalele); assert(algo == Algo::CG || algo == Algo::MATRIX_CG); @@ -1211,13 +1201,11 @@ FixElectrodeConp::~FixElectrodeConp() if (comm->me == 0) { try { if (timer_flag) { - utils::logmesg(lmp, fmt::format("Multiplication time: {:.4g} s\n", mult_time)); - utils::logmesg(lmp, fmt::format("Update time: {:.4g} s\n", update_time)); + utils::logmesg(lmp, "Multiplication time: {:.4g} s\n", mult_time); + utils::logmesg(lmp, "Update time: {:.4g} s\n", update_time); } if (algo == Algo::CG || algo == Algo::MATRIX_CG) - utils::logmesg( - lmp, - fmt::format("Average conjugate gradient steps: {:.4g}\n", n_cg_step * 1. / n_call)); + utils::logmesg(lmp, "Average conjugate gradient steps: {:.4g}\n", n_cg_step * 1. / n_call); } catch (std::exception &) { } } @@ -1304,7 +1292,7 @@ void FixElectrodeConp::read_from_file(const std::string &input_file, double **ar } } if ((bigint) idx.size() != ngroup) - error->all(FLERR, fmt::format("Read tags do not match taglist of electrode/conp")); + error->all(FLERR, "Read tags do not match taglist of fix {}", style); for (bigint i = 0; i < ngroup; i++) { bigint const ii = idx[i]; for (bigint j = 0; j < ngroup; j++) array[i][j] = matrix[ii][idx[j]];