From 01820feacdc4e74e37bdadfc46f9cf3e5478d202 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 4 Jun 2014 22:30:13 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12075 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/USER-AWPMD/atom_vec_wavepacket.cpp | 53 ++++++++++++++++++++++++++ src/USER-AWPMD/atom_vec_wavepacket.h | 2 + src/USER-EFF/atom_vec_electron.cpp | 53 ++++++++++++++++++++++++++ src/USER-EFF/atom_vec_electron.h | 2 + src/compute_property_atom.cpp | 2 + 5 files changed, 112 insertions(+) diff --git a/src/USER-AWPMD/atom_vec_wavepacket.cpp b/src/USER-AWPMD/atom_vec_wavepacket.cpp index 213a770ea1..525262af0c 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.cpp +++ b/src/USER-AWPMD/atom_vec_wavepacket.cpp @@ -1109,6 +1109,59 @@ int AtomVecWavepacket::write_vel_hybrid(FILE *fp, double *buf) return 1; } +/* ---------------------------------------------------------------------- + assign an index to named atom property and return index + return -1 if name is unknown to this atom style +------------------------------------------------------------------------- */ + +int AtomVecWavepacket::property_atom(char *name) +{ + if (strcmp(name,"spin") == 0) return 0; + if (strcmp(name,"eradius") == 0) return 1; + if (strcmp(name,"ervel") == 0) return 2; + if (strcmp(name,"erforce") == 0) return 3; + return -1; +} + +/* ---------------------------------------------------------------------- + pack per-atom data into buf for ComputePropertyAtom + index maps to data specific to this atom style +------------------------------------------------------------------------- */ + +void AtomVecWavepacket::pack_property_atom(int index, double *buf, + int nvalues, int groupbit) +{ + int *mask = atom->mask; + int nlocal = atom->nlocal; + int n = 0; + + if (index == 0) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = spin[i]; + else buf[n] = 0.0; + n += nvalues; + } + } else if (index == 1) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = eradius[i]; + else buf[n] = 0.0; + n += nvalues; + } + } else if (index == 2) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = ervel[i]; + else buf[n] = 0.0; + n += nvalues; + } + } else if (index == 3) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = erforce[i]; + else buf[n] = 0.0; + n += nvalues; + } + } +} + /* ---------------------------------------------------------------------- return # of bytes of allocated memory ------------------------------------------------------------------------- */ diff --git a/src/USER-AWPMD/atom_vec_wavepacket.h b/src/USER-AWPMD/atom_vec_wavepacket.h index 2e13687ad9..fd8a29583c 100644 --- a/src/USER-AWPMD/atom_vec_wavepacket.h +++ b/src/USER-AWPMD/atom_vec_wavepacket.h @@ -71,6 +71,8 @@ public: int pack_vel_hybrid(int, double *); void write_vel(FILE *, int, double **); int write_vel_hybrid(FILE *, double *); + int property_atom(char *); + void pack_property_atom(int, double *, int, int); bigint memory_usage(); private: diff --git a/src/USER-EFF/atom_vec_electron.cpp b/src/USER-EFF/atom_vec_electron.cpp index 7b658f5c25..5935c71402 100644 --- a/src/USER-EFF/atom_vec_electron.cpp +++ b/src/USER-EFF/atom_vec_electron.cpp @@ -973,6 +973,59 @@ int AtomVecElectron::write_vel_hybrid(FILE *fp, double *buf) return 1; } +/* ---------------------------------------------------------------------- + assign an index to named atom property and return index + return -1 if name is unknown to this atom style +------------------------------------------------------------------------- */ + +int AtomVecElectron::property_atom(char *name) +{ + if (strcmp(name,"spin") == 0) return 0; + if (strcmp(name,"eradius") == 0) return 1; + if (strcmp(name,"ervel") == 0) return 2; + if (strcmp(name,"erforce") == 0) return 3; + return -1; +} + +/* ---------------------------------------------------------------------- + pack per-atom data into buf for ComputePropertyAtom + index maps to data specific to this atom style +------------------------------------------------------------------------- */ + +void AtomVecElectron::pack_property_atom(int index, double *buf, + int nvalues, int groupbit) +{ + int *mask = atom->mask; + int nlocal = atom->nlocal; + int n = 0; + + if (index == 0) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = spin[i]; + else buf[n] = 0.0; + n += nvalues; + } + } else if (index == 1) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = eradius[i]; + else buf[n] = 0.0; + n += nvalues; + } + } else if (index == 2) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = ervel[i]; + else buf[n] = 0.0; + n += nvalues; + } + } else if (index == 3) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = erforce[i]; + else buf[n] = 0.0; + n += nvalues; + } + } +} + /* ---------------------------------------------------------------------- return # of bytes of allocated memory ------------------------------------------------------------------------- */ diff --git a/src/USER-EFF/atom_vec_electron.h b/src/USER-EFF/atom_vec_electron.h index 6a202c47fe..23faa2994b 100644 --- a/src/USER-EFF/atom_vec_electron.h +++ b/src/USER-EFF/atom_vec_electron.h @@ -66,6 +66,8 @@ class AtomVecElectron : public AtomVec { int pack_vel_hybrid(int, double *); void write_vel(FILE *, int, double **); int write_vel_hybrid(FILE *, double *); + int property_atom(char *); + void pack_property_atom(int, double *, int, int); bigint memory_usage(); private: diff --git a/src/compute_property_atom.cpp b/src/compute_property_atom.cpp index da88caf325..0c20744a5c 100644 --- a/src/compute_property_atom.cpp +++ b/src/compute_property_atom.cpp @@ -338,6 +338,8 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) : "vector does not exist"); pack_choice[i] = &ComputePropertyAtom::pack_dname; + // check if atom style recognizes keyword + } else { index[i] = atom->avec->property_atom(arg[iarg]); if (index[i] < 0)