set masses from BOP potential files, update unit tests accordingly
This commit is contained in:
@ -95,6 +95,7 @@ PairBOP::PairBOP(LAMMPS *lmp) : Pair(lmp)
|
||||
pairParameters = nullptr;
|
||||
tripletParameters = nullptr;
|
||||
bop_elements = nullptr;
|
||||
bop_masses = nullptr;
|
||||
bop_types = 0;
|
||||
|
||||
pairlist1 = nullptr;
|
||||
@ -183,6 +184,7 @@ PairBOP::~PairBOP()
|
||||
if (bop_elements)
|
||||
for (int i = 0; i < bop_types; i++) delete[] bop_elements[i];
|
||||
delete[] bop_elements;
|
||||
delete[] bop_masses;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -344,16 +346,16 @@ void PairBOP::settings(int narg, char **arg)
|
||||
|
||||
void PairBOP::coeff(int narg, char **arg)
|
||||
{
|
||||
const int n = atom->ntypes;
|
||||
delete [] map;
|
||||
map = new int[n+1];
|
||||
const int np1 = atom->ntypes+1;
|
||||
delete[] map;
|
||||
map = new int[np1];
|
||||
memory->destroy(setflag);
|
||||
memory->destroy(cutsq);
|
||||
memory->destroy(cutghost);
|
||||
memory->create(setflag,n+1,n+1,"BOP:setflag");
|
||||
memory->create(cutsq,n+1,n+1,"BOP:cutsq");
|
||||
memory->create(cutghost,n+1,n+1,"BOP:cutghost");
|
||||
bytes = (n+1)*(n+1) * (sizeof (int) + 2.0*sizeof (double));
|
||||
memory->create(setflag,np1,np1,"BOP:setflag");
|
||||
memory->create(cutsq,np1,np1,"BOP:cutsq");
|
||||
memory->create(cutghost,np1,np1,"BOP:cutghost");
|
||||
bytes = np1*np1*(sizeof (int) + 2.0*sizeof (double));
|
||||
|
||||
map_element2type(narg-3, arg+3);
|
||||
|
||||
@ -365,22 +367,23 @@ void PairBOP::coeff(int narg, char **arg)
|
||||
// and check for missing elements
|
||||
|
||||
if (comm->me == 0) {
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int i = 1; i < np1; i++) {
|
||||
int j;
|
||||
if (map[i] >= 0) {
|
||||
for (j = 0; j < bop_types; j++) {
|
||||
if (strcmp(elements[map[i]],bop_elements[j]) == 0) {
|
||||
if (strcmp(elements[map[i]], bop_elements[j]) == 0) {
|
||||
map[i] = j;
|
||||
atom->set_mass(FLERR, i, bop_masses[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == bop_types)
|
||||
error->one(FLERR,"Element {} not found in bop potential file {}",
|
||||
elements[map[i]],arg[2]);
|
||||
elements[map[i]], arg[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
MPI_Bcast(map,atom->ntypes+1,MPI_INT,0,world);
|
||||
MPI_Bcast(map,np1,MPI_INT,0,world);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1844,9 +1847,10 @@ void PairBOP::read_table(char *filename)
|
||||
PotentialFileReader *reader = nullptr;
|
||||
|
||||
if (bop_elements) {
|
||||
for (int i = 0; i < bop_types; i++) delete [] bop_elements[i];
|
||||
delete [] bop_elements;
|
||||
for (int i = 0; i < bop_types; i++) delete[] bop_elements[i];
|
||||
delete[] bop_elements;
|
||||
}
|
||||
delete[] bop_masses;
|
||||
|
||||
if (comm->me == 0) {
|
||||
try {
|
||||
@ -1857,10 +1861,11 @@ void PairBOP::read_table(char *filename)
|
||||
"elements",bop_types));
|
||||
|
||||
bop_elements = new char*[bop_types];
|
||||
bop_masses = new double[bop_types];
|
||||
for (int i=0; i < bop_types; ++i) {
|
||||
ValueTokenizer values = reader->next_values(3);
|
||||
values.next_int(); // element number in PTE (ignored)
|
||||
values.next_double(); // element mass (ignored)
|
||||
values.next_int(); // element number (ignored)
|
||||
bop_masses[i] = values.next_double(); // element mass
|
||||
bop_elements[i] = utils::strdup(values.next_string());
|
||||
}
|
||||
} catch (TokenizerException &e) {
|
||||
@ -1873,8 +1878,12 @@ void PairBOP::read_table(char *filename)
|
||||
allocate();
|
||||
memory->create(rcut,npairs,"BOP:rcut");
|
||||
|
||||
// copy element labels to all MPI ranks for use with write_tables()
|
||||
if (comm->me != 0) bop_elements = new char*[bop_types];
|
||||
// copy element labels and masses to all MPI ranks for use with
|
||||
// write_tables() and to set the per-type masses
|
||||
if (comm->me != 0) {
|
||||
bop_elements = new char*[bop_types];
|
||||
bop_masses = new double[bop_types];
|
||||
}
|
||||
for (int i = 0; i < bop_types; ++i) {
|
||||
int n=0;
|
||||
if (comm->me == 0) n = strlen(bop_elements[i])+1;
|
||||
@ -1882,6 +1891,7 @@ void PairBOP::read_table(char *filename)
|
||||
if (comm->me != 0) bop_elements[i] = new char[n];
|
||||
MPI_Bcast(bop_elements[i],n,MPI_CHAR,0,world);
|
||||
}
|
||||
MPI_Bcast(bop_masses, bop_types, MPI_DOUBLE, 0, world);
|
||||
|
||||
if (comm->me == 0) {
|
||||
try {
|
||||
@ -2010,7 +2020,7 @@ void PairBOP::read_table(char *filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] singletable;
|
||||
delete[] singletable;
|
||||
|
||||
singletable = new double[nr];
|
||||
for (int i = 0; i < npairs; i++) {
|
||||
@ -2038,7 +2048,7 @@ void PairBOP::read_table(char *filename)
|
||||
p.betaP = new TabularFunction();
|
||||
(p.betaP)->set_values(nr, 0.0, rcut[i], singletable);
|
||||
}
|
||||
delete [] singletable;
|
||||
delete[] singletable;
|
||||
|
||||
singletable = new double[nBOt];
|
||||
for (int i = 0; i < npairs; i++) {
|
||||
@ -2048,7 +2058,7 @@ void PairBOP::read_table(char *filename)
|
||||
p.bo = new TabularFunction();
|
||||
(p.bo)->set_values(nBOt, 0.0, 1.0, singletable);
|
||||
}
|
||||
delete [] singletable;
|
||||
delete[] singletable;
|
||||
|
||||
nbuf = 0;
|
||||
for (int i = 0; i < bop_types; i++) {
|
||||
@ -2102,7 +2112,7 @@ void PairBOP::read_table(char *filename)
|
||||
(p.cphi)->set_values(nr, 0.0, rcut[i], singletable);
|
||||
}
|
||||
}
|
||||
delete [] singletable;
|
||||
delete[] singletable;
|
||||
}
|
||||
|
||||
memory->destroy(rcut);
|
||||
|
||||
@ -109,6 +109,7 @@ class PairBOP : public Pair {
|
||||
int npairs; // number of element pairs
|
||||
int ntriples; // number of all triples
|
||||
char **bop_elements; // names of elements in potential file
|
||||
double *bop_masses; // masses of elements in potential file
|
||||
double bytes;
|
||||
|
||||
int otfly; // = 1 faster, more memory, = 0 slower, less memory
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user