diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index b22136efd3..96e7a036b9 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -91,6 +91,7 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : qf = NULL; q1 = NULL; q2 = NULL; + streitz_flag = 0; comm_forward = comm_reverse = 1; @@ -105,7 +106,11 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) : for (int j = 0; j < nprev; ++j ) s_hist[i][j] = t_hist[i][j] = atom->q[i]; - read_file(arg[7]); + if (strcmp(arg[7],"coul/streitz") == 0) { + streitz_flag = 1; + } else { + read_file(arg[7]); + } } @@ -124,11 +129,13 @@ FixQEq::~FixQEq() memory->destroy(shld); - memory->destroy(chi); - memory->destroy(eta); - memory->destroy(gamma); - memory->destroy(zeta); - memory->destroy(zcore); + if (!streitz_flag) { + memory->destroy(chi); + memory->destroy(eta); + memory->destroy(gamma); + memory->destroy(zeta); + memory->destroy(zcore); + } } /* ---------------------------------------------------------------------- */ @@ -587,7 +594,7 @@ double FixQEq::parallel_norm( double *v, int n ) my_sum += v[i]*v[i]; } - MPI_Allreduce(&my_sum, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world); + MPI_Allreduce( &my_sum, &norm_sqr, 1, MPI_DOUBLE, MPI_SUM, world ); return sqrt( norm_sqr ); } diff --git a/src/QEQ/fix_qeq.h b/src/QEQ/fix_qeq.h index fa197254f7..425c1ffedc 100644 --- a/src/QEQ/fix_qeq.h +++ b/src/QEQ/fix_qeq.h @@ -71,6 +71,7 @@ class FixQEq : public Fix { double *chi,*eta,*gamma,*zeta,*zcore; // qeq parameters double *chizj; double **shld; + int streitz_flag; bigint ngroup; diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 6f76ca8c4c..95d0079fe0 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -56,6 +56,8 @@ FixQEqSlater::FixQEqSlater(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else error->all(FLERR,"Illegal fix qeq/slater command"); } + + if (streitz_flag) extract(); } /* ---------------------------------------------------------------------- */ @@ -86,6 +88,33 @@ void FixQEqSlater::init() /* ---------------------------------------------------------------------- */ +void FixQEqSlater::extract() +{ + int ntypes = atom->ntypes; + + memory->create(chi,ntypes+1,"qeq:chi"); + memory->create(eta,ntypes+1,"qeq:eta"); + memory->create(gamma,ntypes+1,"qeq:gamma"); + memory->create(zeta,ntypes+1,"qeq:zeta"); + memory->create(zcore,ntypes+1,"qeq:zcore"); + + Pair *pair = force->pair_match("coul/streitz",1); + if (pair == NULL) error->all(FLERR,"No pair coul/streitz for fix qeq/slater"); + int tmp; + chi = (double *) pair->extract("chi",tmp); + eta = (double *) pair->extract("eta",tmp); + gamma = (double *) pair->extract("gamma",tmp); + zeta = (double *) pair->extract("zeta",tmp); + zcore = (double *) pair->extract("zcore",tmp); + if (chi == NULL || eta == NULL || gamma == NULL + || zeta == NULL || zcore == NULL) + error->all(FLERR, + "Fix qeq/slater could not extract params from pair coul/streitz"); + +} + +/* ---------------------------------------------------------------------- */ + void FixQEqSlater::pre_force(int vflag) { if (update->ntimestep % nevery) return; diff --git a/src/QEQ/fix_qeq_slater.h b/src/QEQ/fix_qeq_slater.h index ebd1efb31f..c0174ee7c1 100644 --- a/src/QEQ/fix_qeq_slater.h +++ b/src/QEQ/fix_qeq_slater.h @@ -37,6 +37,9 @@ class FixQEqSlater : public FixQEq { void compute_H(); double calculate_H(double, double, double, double, double &); double calculate_H_wolf(double, double, double, double, double &); + void extract(); + + class PairCoulStreitz *streitz; }; } #endif