Move NPARAMS_PER_LINE to parent classes
This commit is contained in:
@ -592,7 +592,7 @@ void PairComb::read_file(char *file)
|
||||
PotentialFileReader reader(lmp, file, "COMB");
|
||||
char * line;
|
||||
|
||||
while(line = reader.next_line(Param::NPARAMS_PER_LINE)) {
|
||||
while(line = reader.next_line(NPARAMS_PER_LINE)) {
|
||||
try {
|
||||
ValueTokenizer values(line," \t\n\r\f");
|
||||
|
||||
|
||||
@ -38,6 +38,9 @@ class PairComb : public Pair {
|
||||
virtual double yasu_char(double *, int &);
|
||||
double enegtot;
|
||||
|
||||
static const int NPARAMS_PER_LINE = 49;
|
||||
|
||||
protected:
|
||||
struct Param {
|
||||
double lam11,lam12,lam21,lam22;
|
||||
double c,d,h;
|
||||
@ -56,10 +59,8 @@ class PairComb : public Pair {
|
||||
double coulcut, lcut, lcutsq, hfocor;
|
||||
int ielement,jelement,kelement;
|
||||
int powermint;
|
||||
static const int NPARAMS_PER_LINE = 49;
|
||||
};
|
||||
|
||||
protected:
|
||||
double cutmax; // max cutoff for all elements
|
||||
int nelements; // # of unique elements
|
||||
char **elements; // names of unique elements
|
||||
|
||||
@ -591,7 +591,7 @@ void PairComb3::read_file(char *file)
|
||||
PotentialFileReader reader(lmp, file, "COMB3");
|
||||
char * line;
|
||||
|
||||
while(line = reader.next_line(Param::NPARAMS_PER_LINE)) {
|
||||
while(line = reader.next_line(NPARAMS_PER_LINE)) {
|
||||
try {
|
||||
ValueTokenizer values(line, " \t\n\r\f");
|
||||
|
||||
|
||||
@ -37,6 +37,9 @@ class PairComb3 : public Pair {
|
||||
virtual double combqeq(double *, int &);
|
||||
double enegtot;
|
||||
|
||||
static const int NPARAMS_PER_LINE = 74;
|
||||
|
||||
protected:
|
||||
// general potential parameters
|
||||
struct Param {
|
||||
int ielement,jelement,kelement,powermint;
|
||||
@ -55,11 +58,8 @@ class PairComb3 : public Pair {
|
||||
double veps, vsig, pcna, pcnb, pcnc, pcnd, polz, curl, pcross;
|
||||
double paaa, pbbb;
|
||||
double curlcut1, curlcut2, curl0;
|
||||
static const int NPARAMS_PER_LINE = 74;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
// general setups
|
||||
int nelements; // # of unique elements
|
||||
int ***elem2param; // mapping from element triplets to parameters
|
||||
|
||||
@ -358,7 +358,7 @@ void PairSW::read_file(char *file)
|
||||
PotentialFileReader reader(lmp, file, "Stillinger-Weber");
|
||||
char * line;
|
||||
|
||||
while(line = reader.next_line(Param::NPARAMS_PER_LINE)) {
|
||||
while(line = reader.next_line(NPARAMS_PER_LINE)) {
|
||||
try {
|
||||
ValueTokenizer values(line, " \t\n\r\f");
|
||||
|
||||
|
||||
@ -34,6 +34,9 @@ class PairSW : public Pair {
|
||||
virtual double init_one(int, int);
|
||||
virtual void init_style();
|
||||
|
||||
static const int NPARAMS_PER_LINE = 14;
|
||||
|
||||
protected:
|
||||
struct Param {
|
||||
double epsilon,sigma;
|
||||
double littlea,lambda,gamma,costheta;
|
||||
@ -44,10 +47,8 @@ class PairSW : public Pair {
|
||||
double sigma_gamma,lambda_epsilon,lambda_epsilon2;
|
||||
double c1,c2,c3,c4,c5,c6;
|
||||
int ielement,jelement,kelement;
|
||||
static const int NPARAMS_PER_LINE = 14;
|
||||
};
|
||||
|
||||
protected:
|
||||
double cutmax; // max cutoff for all elements
|
||||
int nelements; // # of unique elements
|
||||
char **elements; // names of unique elements
|
||||
|
||||
@ -404,7 +404,7 @@ void PairTersoff::read_file(char *file)
|
||||
PotentialFileReader reader(lmp, file, "Tersoff");
|
||||
char * line;
|
||||
|
||||
while(line = reader.next_line(Param::NPARAMS_PER_LINE)) {
|
||||
while(line = reader.next_line(NPARAMS_PER_LINE)) {
|
||||
try {
|
||||
ValueTokenizer values(line, " \t\n\r\f");
|
||||
|
||||
|
||||
@ -34,6 +34,10 @@ class PairTersoff : public Pair {
|
||||
virtual void init_style();
|
||||
double init_one(int, int);
|
||||
|
||||
static const int NPARAMS_PER_LINE = 17;
|
||||
|
||||
protected:
|
||||
|
||||
struct Param {
|
||||
double lam1,lam2,lam3;
|
||||
double c,d,h;
|
||||
@ -49,10 +53,8 @@ class PairTersoff : public Pair {
|
||||
double c5,ca1,ca4; // added for TersoffMOD
|
||||
double powern_del;
|
||||
double c0; // added for TersoffMODC
|
||||
static const int NPARAMS_PER_LINE = 17;
|
||||
};
|
||||
|
||||
protected:
|
||||
Param *params; // parameter set for an I-J-K interaction
|
||||
char **elements; // names of unique elements
|
||||
int ***elem2param; // mapping from element triplets to parameters
|
||||
|
||||
@ -45,7 +45,7 @@ PairTersoffMOD::PairTersoffMOD(LAMMPS *lmp) : PairTersoff(lmp) {}
|
||||
|
||||
void PairTersoffMOD::read_file(char *file)
|
||||
{
|
||||
int params_per_line = 20;
|
||||
int params_per_line = NPARAMS_PER_LINE;
|
||||
char **words = new char*[params_per_line+1];
|
||||
|
||||
memory->sfree(params);
|
||||
|
||||
@ -30,6 +30,8 @@ class PairTersoffMOD : public PairTersoff {
|
||||
PairTersoffMOD(class LAMMPS *);
|
||||
~PairTersoffMOD() {}
|
||||
|
||||
static const int NPARAMS_PER_LINE = 20;
|
||||
|
||||
protected:
|
||||
virtual void read_file(char *);
|
||||
virtual void setup_params();
|
||||
|
||||
@ -7,15 +7,17 @@
|
||||
#include "MANYBODY/pair_comb.h"
|
||||
#include "MANYBODY/pair_comb3.h"
|
||||
#include "MANYBODY/pair_tersoff.h"
|
||||
#include "MANYBODY/pair_tersoff_mod.h"
|
||||
|
||||
#include <mpi.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
const int LAMMPS_NS::PairSW::Param::NPARAMS_PER_LINE;
|
||||
const int LAMMPS_NS::PairComb::Param::NPARAMS_PER_LINE;
|
||||
const int LAMMPS_NS::PairComb3::Param::NPARAMS_PER_LINE;
|
||||
const int LAMMPS_NS::PairTersoff::Param::NPARAMS_PER_LINE;
|
||||
const int LAMMPS_NS::PairSW::NPARAMS_PER_LINE;
|
||||
const int LAMMPS_NS::PairComb::NPARAMS_PER_LINE;
|
||||
const int LAMMPS_NS::PairComb3::NPARAMS_PER_LINE;
|
||||
const int LAMMPS_NS::PairTersoff::NPARAMS_PER_LINE;
|
||||
const int LAMMPS_NS::PairTersoffMOD::NPARAMS_PER_LINE;
|
||||
|
||||
class PotenialFileReaderTest : public ::testing::Test {
|
||||
protected:
|
||||
@ -42,8 +44,8 @@ TEST_F(PotenialFileReaderTest, Si) {
|
||||
PotentialFileReader reader(lmp, "Si.sw", "Stillinger-Weber");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto line = reader.next_line(PairSW::Param::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairSW::Param::NPARAMS_PER_LINE);
|
||||
auto line = reader.next_line(PairSW::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairSW::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotenialFileReaderTest, Comb) {
|
||||
@ -51,8 +53,8 @@ TEST_F(PotenialFileReaderTest, Comb) {
|
||||
PotentialFileReader reader(lmp, "ffield.comb", "COMB");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto line = reader.next_line(PairComb::Param::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairComb::Param::NPARAMS_PER_LINE);
|
||||
auto line = reader.next_line(PairComb::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairComb::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotenialFileReaderTest, Comb3) {
|
||||
@ -60,8 +62,8 @@ TEST_F(PotenialFileReaderTest, Comb3) {
|
||||
PotentialFileReader reader(lmp, "ffield.comb3", "COMB3");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto line = reader.next_line(PairComb3::Param::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairComb3::Param::NPARAMS_PER_LINE);
|
||||
auto line = reader.next_line(PairComb3::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairComb3::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotenialFileReaderTest, Tersoff) {
|
||||
@ -69,8 +71,17 @@ TEST_F(PotenialFileReaderTest, Tersoff) {
|
||||
PotentialFileReader reader(lmp, "Si.tersoff", "Tersoff");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto line = reader.next_line(PairTersoff::Param::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairTersoff::Param::NPARAMS_PER_LINE);
|
||||
auto line = reader.next_line(PairTersoff::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairTersoff::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
TEST_F(PotenialFileReaderTest, TersoffMod) {
|
||||
::testing::internal::CaptureStdout();
|
||||
PotentialFileReader reader(lmp, "Si.tersoff.mod", "Tersoff");
|
||||
::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto line = reader.next_line(PairTersoffMOD::NPARAMS_PER_LINE);
|
||||
ASSERT_EQ(utils::count_words(line), PairTersoffMOD::NPARAMS_PER_LINE);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
||||
Reference in New Issue
Block a user