Adding bpm pair write data method, blocking unreadable vol atom property in bond

This commit is contained in:
jtclemm
2024-10-23 11:56:07 -06:00
parent 8e81ac8c42
commit 3bac6d7cde
3 changed files with 36 additions and 1 deletions

View File

@ -450,7 +450,7 @@ void BondBPMSpring::init_style()
if (volume_flag && !id_fix_prop_bond) {
id_fix_prop_bond = utils::strdup("BOND_BPM_SPRING_FIX_PROP_ATOM");
modify->add_fix(fmt::format("{} all property/atom d_vol d_vol0 ghost yes", id_fix_prop_bond));
modify->add_fix(fmt::format("{} all property/atom d_vol d_vol0 ghost yes writedata no", id_fix_prop_bond));
int tmp1, tmp2;
index_vol = atom->find_custom("vol", tmp1, tmp2);

View File

@ -29,6 +29,7 @@ using namespace LAMMPS_NS;
PairBPMSpring::PairBPMSpring(LAMMPS *_lmp) : Pair(_lmp), k(nullptr), ka(nullptr), cut(nullptr), gamma(nullptr)
{
writedata = 1;
anharmonic_flag = 0;
}
@ -327,6 +328,38 @@ void PairBPMSpring::read_restart_settings(FILE *fp)
MPI_Bcast(&anharmonic_flag, 1, MPI_INT, 0, world);
}
/* ----------------------------------------------------------------------
proc 0 writes to data file
------------------------------------------------------------------------- */
void PairBPMSpring::write_data(FILE *fp)
{
if (anharmonic_flag) {
for (int i = 1; i <= atom->ntypes; i++)
fprintf(fp, "%d %g %g %g %g\n", i, k[i][i], cut[i][i], gamma[i][i], ka[i][i]);
} else {
for (int i = 1; i <= atom->ntypes; i++)
fprintf(fp, "%d %g %g %g\n", i, k[i][i], cut[i][i], gamma[i][i]);
}
}
/* ----------------------------------------------------------------------
proc 0 writes all pairs to data file
------------------------------------------------------------------------- */
void PairBPMSpring::write_data_all(FILE *fp)
{
if (anharmonic_flag) {
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp, "%d %d %g %g %g %g\n", i, j, k[i][j], cut[i][j], gamma[i][j], ka[i][j]);
} else {
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp, "%d %d %g %g %g\n", i, j, k[i][j], cut[i][j], gamma[i][j]);
}
}
/* ---------------------------------------------------------------------- */
double PairBPMSpring::single(int i, int j, int itype, int jtype, double rsq, double /*factor_coul*/,

View File

@ -37,6 +37,8 @@ class PairBPMSpring : public Pair {
void read_restart(FILE *) override;
void write_restart_settings(FILE *) override;
void read_restart_settings(FILE *) override;
void write_data(FILE *) override;
void write_data_all(FILE *) override;
double single(int, int, int, int, double, double, double, double &) override;
protected: