fix issues with pair style more/soft and reformat

This commit is contained in:
Axel Kohlmeyer
2021-07-19 01:04:35 -04:00
parent 0cb09786b6
commit f247a2aedf
2 changed files with 13 additions and 11 deletions

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -14,8 +13,6 @@
#include "pair_morse_soft.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "comm.h"
#include "force.h"
@ -24,6 +21,8 @@
#include "math_special.h"
#include "error.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace MathSpecial;
@ -165,7 +164,6 @@ void PairMorseSoft::allocate()
PairMorse::allocate();
int n = atom->ntypes;
memory->create(lambda,n+1,n+1,"pair:lambda");
}
/* ----------------------------------------------------------------------
@ -344,6 +342,7 @@ void PairMorseSoft::write_restart_settings(FILE *fp)
fwrite(&shift_range,sizeof(double),1,fp);
fwrite(&cut_global,sizeof(double),1,fp);
fwrite(&offset_flag,sizeof(int),1,fp);
fwrite(&mix_flag,sizeof(int),1,fp);
}
/* ----------------------------------------------------------------------
@ -358,11 +357,13 @@ void PairMorseSoft::read_restart_settings(FILE *fp)
utils::sfread(FLERR,&shift_range,sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,nullptr,error);
utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,nullptr,error);
}
MPI_Bcast(&nlambda,1,MPI_DOUBLE,0,world);
MPI_Bcast(&shift_range,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
}
@ -385,8 +386,8 @@ void PairMorseSoft::write_data_all(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp,"%d %g %g %g %g\n",i,d0[i][j],alpha[i][j],r0[i][j],
lambda[i][j]);
fprintf(fp,"%d %d %g %g %g %g %g\n",i,j,d0[i][j],alpha[i][j],r0[i][j],
lambda[i][j],cut[i][j]);
}
/* ---------------------------------------------------------------------- */

View File

@ -29,7 +29,8 @@ namespace LAMMPS_NS {
class PairMorseSoft : public PairMorse {
public:
PairMorseSoft(class LAMMPS *lmp) : PairMorse(lmp), lambda(nullptr){};
PairMorseSoft(class LAMMPS *lmp) :
PairMorse(lmp), lambda(nullptr), nlambda(0), shift_range(1.0){};
virtual ~PairMorseSoft();
virtual void compute(int, int);
@ -41,10 +42,10 @@ class PairMorseSoft : public PairMorse {
virtual void write_restart_settings(FILE *);
virtual void read_restart_settings(FILE *);
void write_data(FILE *);
void write_data_all(FILE *);
virtual void write_data(FILE *);
virtual void write_data_all(FILE *);
virtual double single(int, int, int, int, double, double, double, double &);
void *extract(const char *, int &);
virtual void *extract(const char *, int &);
protected:
double **lambda;
@ -52,7 +53,7 @@ class PairMorseSoft : public PairMorse {
int nlambda;
double shift_range;
void allocate();
virtual void allocate();
};
} // namespace LAMMPS_NS