Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
abkein committed Jan 15, 2025
1 parent 9d8efe6 commit 201c2c7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
45 changes: 24 additions & 21 deletions src/compute_cluster_enthropy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

using namespace LAMMPS_NS;

constexpr double planck_constant = 0.18292026;

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

ComputeClusterEnthropy::ComputeClusterEnthropy(LAMMPS* lmp, int narg, char** arg) : Compute(lmp, narg, arg)
Expand All @@ -50,22 +52,31 @@ ComputeClusterEnthropy::ComputeClusterEnthropy(LAMMPS* lmp, int narg, char** arg
// Get cluster/size compute
compute_cluster_size = dynamic_cast<ComputeClusterSizeExt*>(lmp->modify->get_compute_by_id(arg[3]));
if (compute_cluster_size == nullptr) {
error->all(FLERR, "compute cluster/enthropy: Cannot find compute with style 'cluster/size' with id: {}", arg[3]);
error->all(FLERR, "{}: Cannot find compute with style 'cluster/size' with id: {}", style, arg[3]);
}

// Get the critical size
size_cutoff = utils::inumeric(FLERR, arg[4], true, lmp);
if (size_cutoff < 1) { error->all(FLERR, "size_cutoff for compute cluster/enthropy must be greater than 0"); }
size_cutoff = compute_cluster_size->get_size_cutoff();
if ((narg >= 4) && (::strcmp(arg[4], "inherit") != 0)) {
int t_size_cutoff = utils::inumeric(FLERR, arg[4], true, lmp);
if (t_size_cutoff < 1) { error->all(FLERR, "{}: size_cutoff must be greater than 0", style); }
if (t_size_cutoff > size_cutoff) { error->all(FLERR, "{}: size_cutoff cannot be greater than it of compute sizecluster", style); }
}

// Get ke/atom compute
auto ke_computes = lmp->modify->get_compute_by_style("ke/atom");
if (ke_computes.empty()) { error->all(FLERR, "compute cluster/enthropy: Cannot find compute with style 'ke/atom'"); }
compute_ke_atom = ke_computes[0];
compute_ke_atom = lmp->modify->get_compute_by_id(arg[5]);
if (compute_ke_atom == nullptr) { error->all(FLERR, "{}: Cannot find compute with style id '{}'", style, arg[5]); }

// Get pe/atom compute
auto pe_computes = lmp->modify->get_compute_by_style("pe/atom");
if (pe_computes.empty()) { error->all(FLERR, "compute cluster/enthropy: Cannot find compute with style 'pe/atom'"); }
compute_pe_atom = pe_computes[0];
compute_pe_atom = lmp->modify->get_compute_by_id(arg[6]);
if (compute_pe_atom == nullptr) { error->all(FLERR, "{}: Cannot find compute with id '{}'", style, arg[6]); }

// Get entropy/atom compute
compute_entropy_atom = lmp->modify->get_compute_by_id(arg[7]);
if (compute_entropy_atom == nullptr) { error->all(FLERR, "{}: Cannot find compute with id '{}'", style, arg[7]); }

// Get temp/cluster compute
compute_temp_cluster = lmp->modify->get_compute_by_id(arg[8]);
if (compute_temp_cluster == nullptr) { error->all(FLERR, "{}: Cannot find compute with id '{}'", style, arg[8]); }

size_local_rows = size_cutoff + 1;
memory->create(local_temp, size_local_rows + 1, "compute:cluster/enthropy:temp");
Expand All @@ -80,8 +91,8 @@ ComputeClusterEnthropy::ComputeClusterEnthropy(LAMMPS* lmp, int narg, char** arg

ComputeClusterEnthropy::~ComputeClusterEnthropy() noexcept(true)
{
if (local_temp != nullptr) { memory->destroy(local_temp); }
if (temp != nullptr) { memory->destroy(temp); }
memory->destroy(local_temp);
memory->destroy(temp);
}

/* ---------------------------------------------------------------------- */
Expand Down Expand Up @@ -118,15 +129,7 @@ void ComputeClusterEnthropy::compute_local()
const double* kes = compute_ke_atom->vector_atom;
::memset(local_temp, 0.0, size_local_rows * sizeof(double));

// for (const auto &[size, vec] : compute_cluster_size->cIDs_by_size) {
// if (size < size_cutoff) {
// for (const tagint cid : vec) {
// for (const tagint pid : compute_cluster_size->atoms_by_cID[cid]) {
// local_temp[size] += 2 * kes[pid];
// }
// }
// }
// }

}

/* ----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/compute_cluster_enthropy.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class ComputeClusterEnthropy : public Compute {
class ComputeClusterSizeExt *compute_cluster_size = nullptr;
Compute *compute_ke_atom = nullptr;
Compute *compute_pe_atom = nullptr;
Compute *compute_temp_cluster = nullptr;
Compute *compute_entropy_atom = nullptr;

double *temp = nullptr; // array of temps of global clusters
double *local_temp = nullptr; // array of temps of local clusters
Expand Down
13 changes: 8 additions & 5 deletions src/fix_cluster_crush_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,18 @@ void FixClusterCrushDelete::pre_exchange()

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

void FixClusterCrushDelete::deleteAtoms(int atoms2move_local) noexcept(true)
void FixClusterCrushDelete::deleteAtoms(const int atoms2move_local) const noexcept(true)
{
// delete local atoms
// reset nlocal

for (int i = atoms2move_local - 1; i >= 0; --i) { atom->avec->copy(atom->nlocal - atoms2move_local + i, p2m[i], 1); }

atom->nlocal -= atoms2move_local;
} // void FixClusterCrush::delete_monomers(int)
for (int i = 0; i < atoms2move_local; i++) {
if (atom->nlocal < 0) { error->one(FLERR, "{}/deleteAtoms:{}: Negative nlocal", style, comm->me); }
if (p2m[i] < 0) { error->one(FLERR, "{}/deleteAtoms:{}: particle index less than 0", style, comm->me); }
if (p2m[i] >= atom->nlocal) { error->one(FLERR, "{}/deleteAtoms:{}: particle index exceeds nlocal", style, comm->me); }
atom->avec->copy((atom->nlocal--) - 1, p2m[i], 1);
}
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/fix_cluster_crush_delete.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class FixClusterCrushDelete : public Fix {
char *vstr{}, *xstr{}, *ystr{}, *zstr{};
std::array<int, 4> vars{};

void deleteAtoms(int atoms2move_local) noexcept(true);
void deleteAtoms(const int atoms2move_local) const noexcept(true);
void postDelete() noexcept(true);

int add() const;
Expand Down

0 comments on commit 201c2c7

Please sign in to comment.