1 /* -*- c++ -*- ---------------------------------------------------------- 2 LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator 3 www.cs.sandia.gov/~sjplimp/lammps.html 4 Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories 5 6 Copyright (2003) Sandia Corporation. Under the terms of Contract 7 DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains 8 certain rights in this software. This software is distributed under 9 the GNU General Public License. 10 11 See the README file in the top-level LAMMPS directory. 12 ------------------------------------------------------------------------- */ 13 /* ---------------------------------------------------------------------- 14 Contributing authors: 15 Ling-Ti Kong 16 17 Contact: 18 School of Materials Science and Engineering, 19 Shanghai Jiao Tong University, 20 800 Dongchuan Road, Minhang, 21 Shanghai 200240, CHINA 22 23 konglt@sjtu.edu.cn; konglt@gmail.com 24 ------------------------------------------------------------------------- */ 25 26 #ifdef FIX_CLASS 27 // clang-format off 28 FixStyle(phonon,FixPhonon); 29 // clang-format on 30 #else 31 32 #ifndef FIX_PHONON_H 33 #define FIX_PHONON_H 34 35 #ifdef FFT_SINGLE 36 typedef float FFT_SCALAR; 37 #define MPI_FFT_SCALAR MPI_FLOAT 38 #else 39 typedef double FFT_SCALAR; 40 #define MPI_FFT_SCALAR MPI_DOUBLE 41 #endif 42 43 #include "fix.h" 44 #include <complex> 45 #include <map> 46 47 namespace LAMMPS_NS { 48 49 class FixPhonon : public Fix { 50 public: 51 FixPhonon(class LAMMPS *, int, char **); 52 ~FixPhonon(); 53 54 int setmask(); 55 void init(); 56 void setup(int); 57 void end_of_step(); 58 void post_run(); 59 double memory_usage(); 60 int modify_param(int, char **); 61 62 private: 63 int me, nprocs; 64 bigint waitsteps; // wait these number of timesteps before recording atom positions 65 bigint prev_nstep; // number of steps from previous run(s); to judge if waitsteps is reached. 66 int nfreq, ifreq; // after this number of measurement (nfreq), the result will be output once 67 int nx, ny, nz, nucell, 68 ntotal; // surface dimensions in x- and y-direction, number of atom per unit surface cell 69 int neval; // # of evaluations 70 int sysdim; // system dimension 71 int ngroup, nfind; // total number of atoms in group; total number of atoms on this proc 72 char *prefix, *logfile; // prefix of output file names 73 FILE *flog; 74 75 double *M_inv_sqrt; 76 77 class FFT3d *fft; // to do fft via the fft3d wrapper 78 int nxlo, nxhi, mysize; // size info for local MPI_FFTW 79 int mynpt, mynq, fft_nsend; 80 int *fft_cnts, *fft_disp; 81 int fft_dim, fft_dim2; 82 FFT_SCALAR *fft_data; 83 84 tagint itag; // index variables 85 int idx, idq; // more index variables 86 std::map<tagint, int> tag2surf; // Mapping info 87 std::map<int, tagint> surf2tag; // more Mapping info 88 89 double **RIloc; // R(r) and index on local proc 90 double **RIall; // gathered R(r) and index 91 double **Rsort; // sorted R(r) 92 double **Rnow; // Current R(r) on local proc 93 double **Rsum; // Accumulated R(r) on local proc 94 95 int *recvcnts, *displs; // MPI related variables 96 97 std::complex<double> **Rqnow; // Current R(q) on local proc 98 std::complex<double> **Rqsum; // Accumulator for conj(R(q)_alpha)*R(q)_beta 99 std::complex<double> **Phi_q; // Phi's on local proc 100 std::complex<double> **Phi_all; // Phi for all 101 102 void readmap(); // to read the mapping of gf atoms 103 char *mapfile; // file name of the map file 104 105 void getmass(); // to get the mass of each atom in a unit cell 106 107 int nasr; 108 void postprocess(); // to post process the data 109 void EnforceASR(); // to apply acoustic sum rule to gamma point force constant matrix 110 111 char *id_temp; // compute id for temperature 112 double *TempSum; // to get the average temperature vector 113 double inv_nTemp; // inverse of number of atoms in temperature group 114 class Compute *temperature; // compute that computes the temperature 115 116 double hsum[6], **basis; 117 int *basetype; 118 119 // private methods to do matrix inversion 120 void GaussJordan(int, std::complex<double> *); 121 }; 122 } // namespace LAMMPS_NS 123 #endif 124 #endif 125 126 /* ERROR/WARNING messages: 127 128 E: Illegal fix phonon command... 129 130 Self-explanatory. Check the input script syntax and compare to the 131 documentation for the command. You can use -echo screen as a 132 command-line option when running LAMMPS to see the offending line. 133 134 E: No atom found for fix phonon! 135 136 Self-explanatory. Number of atoms in the group that was passed to 137 fix-phonon is less than 1. 138 139 E: Can not open output file %s" 140 141 Self-explanatory. 142 143 E: Illegal fix_modify command 144 145 Self-explanatory. 146 147 E: Could not find fix_modify temp ID 148 149 Self-explanatory. 150 151 E: Fix_modify temp ID does not compute temperature 152 153 Self-explanatory. 154 155 E: Cannot open input map file %s 156 157 Self-explanatory. 158 159 E: Error while reading header of mapping file! 160 161 Self-explanatory. The first line of the map file is expected to 162 contain 4 positive integer numbers. 163 164 E: FFT mesh and number of atoms in group mismatch! 165 166 Self-explanatory. The product of the 4 numbers should be exactly the 167 total number of atoms in the group that was passed to fix-phonon. 168 169 E: Error while reading comment of mapping file! 170 171 Self-explanatory. The second line of the map file should be a comment line. 172 173 E: The mapping is incomplete! 174 175 Self-explanatory. 176 177 E: Error while reading mapping file! 178 179 Self-explanatory. 180 181 E: The mapping info read is incorrect! 182 183 Self-explanatory. 184 185 E: Singular matrix in complex GaussJordan! 186 187 Self-explanatory. 188 189 W: More than one fix phonon defined 190 191 Self-explanatory. Just to warn that more than one fix-phonon is defined, but allowed. 192 193 */ 194