00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "meam-baskes.h"
00010
00011
00012 void MEAMFrame::Alloc()
00013 {
00014 MDPARALLELFrame::Alloc();
00015 }
00016
00017 void MEAMFrame::potential()
00018 {
00019 MEAM();
00020 }
00021
00022 void MEAMFrame::readMEAM()
00023 {
00024 LFile::SubHomeDir(mea_.meamf,mea_.meamf);
00025 LFile::SubHomeDir(mea_.meafile,mea_.meafile);
00026 myoutput_.fid = 24;
00027 inter_();
00028
00029 if(cneigh_.dradn<0)
00030 cneigh_.dradn = 0.1*interact_.rcut;
00031
00032 interact_.rcutsq = interact_.rcut*interact_.rcut;
00033
00034 _RLIST= interact_.rcut + cneigh_.dradn;
00035 _SKIN = cneigh_.dradn;
00036
00037 cneigh_.rctsqn = _RLIST*_RLIST;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 WARNING("***************************************************************************");
00052 WARNING("The MEAM potential is only implemented for rectangular supercells!");
00053 WARNING("It won't work correctly for tilted supercells (e.g. with dislocation dipole)");
00054 WARNING("***************************************************************************");
00055 }
00056
00057 void MEAMFrame::MEAM()
00058 {
00059 Vector3 h;
00060 int i, j;
00061 double eps;
00062
00063
00064
00065 lattice_.natoms=_NP;
00066
00067 if(_NP > natmax)
00068 {
00069 INFO_Printf("meam-baskes: NP = %d exceeds limit %d (meam-lammps does not have this limit)\n",_NP,natmax);
00070 return;
00071 }
00072
00073 SHtoR();
00074 for(i=0;i<_NP;i++)
00075 {
00076 particle_.rv[i][0]=_R[i].x;
00077 particle_.rv[i][1]=_R[i].y;
00078 particle_.rv[i][2]=_R[i].z;
00079 particle_.itype[i] = species[i]+1;
00080 }
00081 lattice_.perlen[0]=_H[0][0];
00082 lattice_.perlen[1]=_H[1][1];
00083 lattice_.perlen[2]=_H[2][2];
00084
00085 eps=1e-8;
00086 if ( (fabs(_H[0][1])>eps)||(fabs(_H[0][2])>eps)||
00087 (fabs(_H[1][0])>eps)||(fabs(_H[1][2])>eps)||
00088 (fabs(_H[2][0])>eps)||(fabs(_H[2][1])>eps) )
00089 {
00090 _INFO(_H);
00091 WARNING(" Only rectangular supercell is allowed!");
00092 }
00093
00094
00095 force_();
00096
00097 _EPOT=0;
00098 for(i=0;i<_NP;i++)
00099 {
00100 _F[i].set(forces_.f[i][0],forces_.f[i][1],forces_.f[i][2]);
00101 _EPOT_IND[i] = forces_.e[i];
00102 _EPOT += forces_.e[i];
00103 _VIRIAL_IND[i].set(forces_.slocal[i][0][0],forces_.slocal[i][1][0],forces_.slocal[i][2][0],
00104 forces_.slocal[i][0][1],forces_.slocal[i][1][1],forces_.slocal[i][2][1],
00105 forces_.slocal[i][0][2],forces_.slocal[i][1][2],forces_.slocal[i][2][2]);
00106 }
00107 for(i=0;i<3;i++)
00108 for(j=0;j<3;j++)
00109 _VIRIAL[i][j]=forces_.stresst[j][i];
00110
00111 }
00112
00113 void MEAMFrame::initvars()
00114 {
00115 MDPARALLELFrame::initvars();
00116 }
00117
00118 void MEAMFrame::initparser()
00119 {
00120 MDPARALLELFrame::initparser();
00121 bindvar("meamfile",mea_.meamf,STRING);
00122 bindvar("meafile",mea_.meafile,STRING);
00123 bindvar("ntypes",&types_.ntypes,INT);
00124 bindvar("ename0",cmeam_.enames[0],STRING);
00125 bindvar("ename1",cmeam_.enames[1],STRING);
00126 bindvar("ename2",cmeam_.enames[2],STRING);
00127 bindvar("rcut",&interact_.rcut,DOUBLE);
00128
00129 bindvar("kode0",kodes_.kodes[0],STRING);
00130 bindvar("kode1",kodes_.kodes[0],STRING);
00131 bindvar("kode2",kodes_.kodes[0],STRING);
00132 }
00133
00134 int MEAMFrame::exec(char *name)
00135 {
00136 if(MDPARALLELFrame::exec(name)==0) return 0;
00137 bindcommand(name,"readMEAM",readMEAM());
00138 bindcommand(name,"printpairpot",printpairpot());
00139
00140 return -1;
00141 }
00142
00143 void MEAMFrame::printpairpot()
00144 {
00145 int elti, eltj;
00146 double rmin, dr, rmax, r, phi, phip;
00147 char pairfile[200];
00148 FILE *fp;
00149
00150 elti = (int) input[0] + 1;
00151 eltj = (int) input[1] + 1;
00152 rmin = input[2];
00153 dr = input[3];
00154 rmax = input[4];
00155
00156 strcpy(pairfile,"pairpot_baskes.dat");
00157 fp=fopen(pairfile,"w");
00158 if(fp==NULL)
00159 {
00160 FATAL("printpairpot: file "<<pairfile<<" open failure.");
00161 }
00162 if((rmax<rmin)||(dr<=0))
00163 FATAL("rmax cannot be smaller than rmin, dr must be positive");
00164
00165 phip = 0;
00166 for(r=rmin;r<=rmax;r+=dr)
00167 {
00168
00169
00170 calphiid_(&r,&elti,&phi);
00171 fprintf(fp,"%21.14e %21.14e %21.14e\n",r,phi,phip);
00172 }
00173 fclose(fp);
00174 INFO("results written to "<<pairfile);
00175 }
00176
00177
00178 #ifdef _TEST
00179
00180
00181 class MEAMFrame sim;
00182
00183
00184 #include "main.cpp"
00185
00186 #endif//_TEST
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 #if 0
00251
00252 inline double interp(double func[],double deriv[],double dr,int ind,double qq)
00253 {
00254 double f, a, b, c, d, f1, p1, A1, A2, dr2, dr3, qq2, qq3;
00255
00256 dr2=dr*dr; dr3=dr2*dr;
00257 qq2=qq*qq; qq3=qq2*qq;
00258 a = func[ind];
00259 b = deriv[ind];
00260 f1 = func[ind+1];
00261 p1 = deriv[ind+1];
00262 A1 = f1-a-b*dr;
00263 A2 = (p1-b)*dr;
00264 d = (A2-2*A1)/dr3;
00265 c = (3*A1-A2)/dr2;
00266 f=a+b*qq+c*qq2+d*qq3;
00267 return f;
00268 }
00269
00270
00271 inline double interp1(double func[],double deriv[],double dr,int ind,double qq)
00272 {
00273 double fp, a, b, c, d, f1, p1, A1, A2, dr2, dr3, qq2, qq3;
00274
00275 dr2=dr*dr; dr3=dr2*dr;
00276 qq2=qq*qq; qq3=qq2*qq;
00277 a = func[ind];
00278 b = deriv[ind];
00279 f1 = func[ind+1];
00280 p1 = deriv[ind+1];
00281 A1 = f1-a-b*dr;
00282 A2 = (p1-b)*dr;
00283 d = (A2-2*A1)/dr3;
00284 c = (3*A1-A2)/dr2;
00285 fp=b+2*c*qq+3*d*qq2;
00286 return fp;
00287 }
00288 #endif