Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for extep when NULL or only some elements from potential file are used. #1494

Merged
merged 2 commits into from Jun 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/USER-MISC/pair_extep.cpp
Expand Up @@ -19,6 +19,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include "pair_extep.h"
#include "atom.h"
#include "neighbor.h"
Expand Down Expand Up @@ -705,7 +706,7 @@ void PairExTeP::read_file(char *file)
error->all(FLERR,"Illegal ExTeP parameter");

nparams++;
if (nparams >= pow(atom->ntypes,3)) break;
if (nparams >= pow(nelements,3)) break;
}

// deallocate words array
Expand Down Expand Up @@ -746,14 +747,24 @@ void PairExTeP::read_file(char *file)
nwords = atom->count_words(line);
if (nwords == 0) continue;

if (nwords != params_per_line)
error->all(FLERR,"Incorrect format in ExTeP potential file");

// words = ptrs to all words in line

nwords = 0;
words[nwords++] = strtok(line," \t\n\r\f");
while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;
while ((nwords < params_per_line)
&& (words[nwords++] = strtok(NULL," \t\n\r\f"))) continue;

// skip line if it is a leftover from the previous section,
// which can be identified by having 3 elements (instead of 2)
// as first words.

if (isupper(words[0][0]) && isupper(words[1][0]) && isupper(words[2][0]))
continue;

// need to have two elements followed by a number in each line
if (!(isupper(words[0][0]) && isupper(words[1][0])
&& !isupper(words[2][0])))
error->all(FLERR,"Incorrect format in ExTeP potential file");

// ielement,jelement = 1st args
// if all 3 args are in element list, then parse this line
Expand Down Expand Up @@ -1074,8 +1085,8 @@ void PairExTeP::costheta_d(double *rij_hat, double rij,
// initialize spline for F_corr (based on PairLCBOP::F_conj)

void PairExTeP::spline_init() {
for ( int iel=0; iel<atom->ntypes; iel++) {
for ( int jel=0; jel<atom->ntypes; jel++) {
for ( int iel=0; iel<nelements; iel++) {
for ( int jel=0; jel<nelements; jel++) {
for ( int N_ij=0; N_ij<4; N_ij++ ) {
for ( int N_ji=0; N_ji<4; N_ji++ ) {
TF_corr_param &f = F_corr_param[iel][jel][N_ij][N_ji];
Expand Down