00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _MD_H
00025 #define _MD_H
00026
00027 #include <math.h>
00028 #include <stdio.h>
00029 #include <stdlib.h>
00030
00031 #ifdef _USETCL
00032 #include "tcl.h"
00033 #ifdef _USETK
00034 #include "tk.h"
00035 #endif
00036 #endif
00037
00038 #ifdef _USEFFTW
00039 #include "fftw3.h"
00040 #else
00041 #define fftw_plan int
00042 #endif
00043
00044 #include "general.h"
00045 #include "organizer.h"
00046 #include "display.h"
00047 #include "linalg3.h"
00048 #include "relax.h"
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #define AVO 6.0221367E+23
00063 #define EV 1.6021772E-19
00064 #define BOLZ 1.380658E-23
00065 #define KB 0.8617336E-4
00066 #define PLANCK_H 4.135667e-15
00067
00068
00069 #define MASSCONVERT 1e-3/AVO/EV/1e20*1e24
00070
00071
00072 #define P_CLMB_E 1.0 // for the correction of Coulomb potential (dielectric function constant)
00073 #define P_CLMB (P_E*P_E/P_E*1.0e10)/(4.0*M_PI*P_EPSILON0*P_CLMB_E) // (eV*A) conversion factor for the Coulomb force
00074 #define P_SQRT_CLMB sqrt(P_CLMB) //3.79470135954879
00075 #define M_SQRT_PI sqrt(M_PI) //1.77245385090552
00076
00077
00078 #ifndef max
00079 #define max(a,b) (((a)>(b))?(a):(b))
00080 #endif
00081 #ifndef min
00082 #define min(a,b) (((a)<(b))?(a):(b))
00083 #endif
00084
00085 #ifndef SQR
00086 #define SQR(A) ((A)*(A))
00087 #endif
00088
00089 #ifndef CUBE
00090 #define CUBE(A) ((A)*(A)*(A))
00091 #endif
00092
00093 #ifndef POW6
00094 #define POW6(A) SQR(CUBE(A))
00095 #endif
00096
00097 #ifndef POW12
00098 #define POW12(A) SQR(POW6(A))
00099 #endif
00100
00101 #define PME_int_mod(x,y) (((x%y)+y)%y)
00102
00103 #define MAXSPECIES 10
00104 #define MAXCOLORS 10
00105 #define MAXCONSTRAINATOMS 2001
00106 #define MAXCMDLEN 1000
00107 #define MAXNHCLEN 20
00108
00109
00110 #ifdef _NODRAND48
00111 #define drand48 (1.0/RAND_MAX)*rand
00112 #endif
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 #define Realloc(p,t,s) {p=(t *)realloc(p,sizeof(t)*s);}
00123 #define bindcommand_sync bindcommand
00124
00125
00126
00127
00128 class CNFile : public AUXFile
00129 {
00130 public:
00131 CNFile(int t):AUXFile(t){};
00132 virtual char * describe();
00133 private:
00134 virtual int writeblock(void *p);
00135 virtual int readblock(void *p);
00136 };
00137
00138 class POSCARFile : public AUXFile
00139 {
00140 public:
00141 POSCARFile(int t):AUXFile(t){};
00142 virtual char * describe();
00143 private:
00144 virtual int writeblock(void *p);
00145 virtual int readblock(void *p);
00146 };
00147
00148 class LAMMPSFile : public AUXFile
00149 {
00150 public:
00151 LAMMPSFile(int t):AUXFile(t){};
00152 virtual char * describe();
00153 private:
00154 virtual int writeblock(void *p);
00155 virtual int readblock(void *p);
00156 };
00157
00158 class AVGCNFile : public AUXFile
00159 {
00160 public:
00161 AVGCNFile(int t):AUXFile(t){};
00162 private:
00163 virtual int writeblock(void *p);
00164 virtual int readblock(void *p);
00165 };
00166
00167 class MDCASKconFile : public AUXFile
00168 {
00169 public:
00170 MDCASKconFile(int t):AUXFile(t){};
00171 virtual char * describe();
00172 private:
00173 virtual int writeblock(void *p);
00174 virtual int readblock(void *p);
00175 };
00176
00177 class MDCASKinputFile : public AUXFile
00178 {
00179 public:
00180 MDCASKinputFile(int t):AUXFile(t){};
00181 virtual char * describe();
00182 private:
00183 virtual int writeblock(void *p);
00184 virtual int readblock(void *p);
00185 };
00186
00187 class PropFile : public AUXFile
00188 {
00189 public:
00190 PropFile(int t):AUXFile(t){};
00191 virtual char * describe();
00192 virtual int writeentry(void *p);
00193 };
00194
00195
00196
00197
00198
00199 struct EComplex
00200 {
00201 double Re, Im;
00202 public:
00203 double Norm() { return sqrt(Re*Re+Im*Im); }
00204 double Norm2() { return Re*Re+Im*Im; }
00205
00206 static void Mul(const EComplex &a, const EComplex &b, EComplex &c)
00207 {
00208 double tmp=a.Re*b.Re-a.Im*b.Im;
00209 c.Im=a.Re*b.Im+a.Im*b.Re;
00210 c.Re=tmp;
00211 }
00212 static void MulConjugate(const EComplex &a, const EComplex &b, EComplex &c)
00213 {
00214 c.Re=a.Re*b.Re+a.Im*b.Im;
00215 c.Im=-a.Re*b.Im+a.Im*b.Re;
00216 }
00217 EComplex &operator *=(double d)
00218 {
00219 Re*=d;
00220 Im*=d;
00221 return *this;
00222 }
00223 EComplex &operator +=(EComplex &c)
00224 {
00225 Re+=c.Re;
00226 Im+=c.Im;
00227 return *this;
00228 }
00229 EComplex &operator -=(EComplex &c)
00230 {
00231 Re-=c.Re;
00232 Im-=c.Im;
00233 return *this;
00234 }
00235 void ExpI(double theta)
00236 {
00237 Re=cos(theta);
00238 Im=sin(theta);
00239 }
00240 EComplex &operator =(double d)
00241 {
00242 Re=d;
00243 Im=0.0;
00244 return *this;
00245 }
00246 friend LOStream &operator <<(LOStream &os, EComplex &c)
00247 {
00248 return os << "["<<c.Re<<"(+)"<<c.Im<<"(I)]";
00249 }
00250 };
00251
00252
00253
00254
00255 typedef double ComplexType[2];
00256
00257
00258 class MDFrame : public Organizer
00259 {
00260 public:
00261 int _SAVEMEMORY;
00262 int _NP;
00263 int _NP0, _NIMAGES;
00264 int _NPfree,_NPfixed;
00265
00266 class Vector3 *_R, *_SR;
00267 class Vector3 *_SRA;
00268 class Vector3 *_VR, *_VSR;
00269 class Vector3 *_F, *_F0;
00270 class Vector3 *_R0;
00271 class Vector3 *_Fext;
00272 int _ENABLE_FEXT;
00273
00274 int *fixed;
00275 int *image;
00276 int *species;
00277 int *group;
00278 int nspecies;
00279 char element[MAXSPECIES][10];
00280
00281 class Matrix33 _H, _H0;
00282 class Matrix33 _VIRIAL, _VH;
00283 class Matrix33 *_VIRIAL_IND;
00284 double _EPOT, *_EPOT_IND;
00285 double *_EPOT_RMV;
00286 double _EPOT_BOX;
00287 double _EPOT0;
00288 double _EPOT0_ext;
00289 double *_TOPOL;
00290
00291
00292 double _ESTRAIN;
00293 double _OMEGA;
00294 double _KATOM, _KBOX;
00295 double _ATOMMASS[MAXSPECIES], _WALLMASS;
00296 double _ATOMCHARGE[MAXSPECIES];
00297 double _TIMESTEP;
00298 double _TDES,_T;
00299 int _DOUBLET;
00300 double _ATOMTCPL,_BOXTCPL;
00301 double _BOXDAMP;
00302 double zeta,zetav,zetaa,vt2;
00303 double _HELM,_HELMP;
00304
00305
00306 int applyshear;
00307 double extforce[100];
00308 double forcemul;
00309 Matrix33 _SHEARRATE;
00310 int runavgposition;
00311
00312
00313 double _RLIST,_SKIN;
00314 int _NIC, _current_NIC;
00315 int _NNM, _current_NNM;
00316 int *nn;
00317 int **nindex;
00318
00319 int *link_head, *link_list;
00320
00321 int ****celllist;
00322 char *cell_mem, *nindex_mem;
00323 bool firsttime;
00324
00325 double rc_plot;
00326 int _NNM_plot;
00327 int *nn_plot;
00328 int **nindex_plot;
00329 char *nindex_plot_mem;
00330
00331
00332 Vector3 *s2, *s3, *s4, *s5, *s2real;
00333 class Matrix33 h2,h3,h4,h5,h2real;
00334 double zeta2,zeta3,zeta4,zeta5;
00335 int npold;
00336 int NHChainLen;
00337 double zetaNHC[MAXNHCLEN], zetaNHCv[MAXNHCLEN], zetaNHCa[MAXNHCLEN],
00338 zetaNHC2[MAXNHCLEN], zetaNHC3[MAXNHCLEN], zetaNHC4[MAXNHCLEN], zetaNHC5[MAXNHCLEN];
00339 double NHMass[MAXNHCLEN];
00340
00341
00342
00343
00344
00345
00346
00347 class Matrix33 _PSTRESS;
00348 class Matrix33 _TOTSTRESS;
00349 class Matrix33 _TOTSTRESSinMPa;
00350 class Matrix33 _EXTSTRESS;
00351 double _TOTPRESSURE;
00352 double _EXTSTRESSMUL;
00353 double _EXTPRESSADD;
00354 double _VACUUMRATIO;
00355 class Matrix33 _DVIRIAL_Dexx;
00356 double _Dexx;
00357
00358
00359 int conj_itmax,conj_fevalmax,conj_fixbox,conj_fixshape,
00360 conj_fixatoms,conj_step,conj_ier,conj_fixdir;
00361 class Matrix33 conj_fixboxvec;
00362 double conj_dfpred,conj_f,conj_ftol,conj_g2res;
00363 double *conj_space;
00364 double _HPRECOND;
00365 double _XPRECOND,_YPRECOND,_ZPRECOND;
00366 class Matrix33 _SIGMA;
00367 class Matrix33 _GH;
00368
00369
00370 double constrainS, constrainS_inst, constrain_dist, constrainF;
00371 int constrainatoms[MAXCONSTRAINATOMS];
00372
00373
00374 int _constrainedMD;
00375
00376
00377 int totalsteps, equilsteps, curstep, step0, continue_curstep;
00378 char ensemble_type[100], integrator_type[100]; int implementation_type;
00379 int algorithm_id;
00380
00381
00382 int MC_atom, MC_accept, MC_accept_tot, MC_switchoffatoms[10];
00383 int MC_dV_freq, MC_dN_freq;
00384 double MC_accept_ratio, MC_dVmax, MC_dfrac, MC_P_ext, MC_mu_ext, MC_Lambda3, MC_fracatom;
00385 Vector3 MC_dr;
00386
00387
00388 double _LAMBDA, _LAMBDA0, _LAMBDA1, dEdlambda, dlambdadt, _ECOH, _WTOT, _WAVG;
00389 int _ENABLE_SWITCH, _SWITCHFREQ, _RANDSEED, _CHAINLENGTH, _SWITCHFUNC, _REFPOTENTIAL;
00390 int heslen, *hesind; double *hes;
00391 double _ECSPRING;
00392 double _I12_RC, _I12_SIGMA, _I12_EPSILON;
00393 double _GAUSS_RC, _GAUSS_SIGMA, _GAUSS_EPSILON;
00394
00395
00396 class Vector3 *_SR1, *_SR2, *_SR3;
00397 class Vector3 dscom12;
00398 class Vector3 _COM;
00399 class Vector3 **_Rc, **_Fc;
00400 double *_nebinterp;
00401 int nebspec[10];
00402 int readparallelnebcn;
00403 double annealspec[10];
00404
00405
00406 double *_QLM, *_QL;
00407 int *_Lam_array, *_Lam_check;
00408 int L_for_QLM;
00409 int N_solid_P;
00410 int N_skin_P;
00411 int N_lgst_cluster;
00412 double Rc_for_QLM;
00413 double QLM_cutoff;
00414 int *QLM_mark;
00415 int *QLM_solid;
00416 int N_cluster_temp;
00417 Vector3 Principal_Inertia;
00418 double N_lgst_index;
00419 double N_lgst_skin;
00420 double N_lgst_skin_index;
00421
00422 int wSKIN;
00423 int saveFFScn;
00424 int FFSoption;
00425 int FFSpruning;
00426 double FFScn_weight;
00427 double FFS_Pp;
00428 int FFS0_check;
00429 int FFS_i;
00430 int FFS_i_plus;
00431 int FFS_i_minus;
00432
00433
00434 Vector3 *_F_Ewald, *_F_Ewald_Real, *_F_Ewald_Rec;
00435 double *_EPOT_IND_Ewald, *_EPOT_IND_Ewald_Real, *_EPOT_IND_Ewald_Rec;
00436 Matrix33 _VIRIAL_Ewald, _VIRIAL_Ewald_Real, _VIRIAL_Ewald_Rec;
00437 int Ewald_CE_or_PME;
00438 int Ewald_option_Alpha;
00439 double Ewald_Rcut;
00440 double Ewald_precision;
00441 double Ewald_time_ratio;
00442 double _EPOT_Ewald, _EPOT_Ewald_Real, _EPOT_Ewald_Rec, _EPOT_Ewald_Self;
00443 double Ewald_Alpha, Ewald_qSQRsum;
00444 double Ewald_H_L1, Ewald_H_L2, Ewald_H_L3, Ewald_cell_V;
00445
00446 int CE_MKV, CE_nKV;
00447 int CE_Mka, CE_Mkb, CE_Mkc;
00448 double CE_Kc;
00449
00450 struct K_rec { double kx, ky, kz, k2; int a,b,c; } *CE_KV;
00451 EComplex *CE_sc_axby, *CE_sckk;
00452 EComplex **CE_scx, **CE_scy, **CE_scz;
00453
00454 clock_t CE_sREAL, CE_sREC, CE_eREAL, CE_eREC;
00455 double CE_iREAL, CE_iREC, CE_tREAL, CE_tREC;
00456
00457
00458 int PME_bsp_n;
00459
00460 int PME_K1, PME_K2, PME_K3, PME_K3S;
00461 int PME_K23, PME_K123, PME_K23S, PME_K123S;
00462 double PME_K1d, PME_K2d, PME_K3d, PME_K123d;
00463
00464 Vector3 *_UR;
00465
00466 double *PME_B;
00467 double *PME_C;
00468 double *PME_BC;
00469 double *PME_Q;
00470 double *PME_CONV;
00471 ComplexType *PME_IQ;
00472
00473 ComplexType PME_R_bsp_Bm;
00474 double *PME_bsp_Mk;
00475 double *PME_bsp_fac;
00476
00477 int *PME_m1s, *PME_m2s, *PME_m3s;
00478 int *PME_m1, *PME_m2, *PME_m3;
00479 int *PME_m1mod, *PME_m2mod, *PME_m3mod;
00480
00481 double *PME_x1, *PME_x2, *PME_x3;
00482 double *PME_MU1, *PME_MU2, *PME_MU3;
00483 double *PME_d1MU1, *PME_d1MU2, *PME_d1MU3;
00484 double *PME_d2MU1, *PME_d2MU2, *PME_d2MU3;
00485
00486 fftw_plan PME_fft_plan1, PME_fft_plan2;
00487
00488 clock_t PME_sREC, PME_eREC;
00489 double PME_iREC, PME_tREC;
00490
00491
00492 class Vector3 *storedr;
00493 class Matrix33 dH;
00494 char crystalstructure[30];
00495 double latticeconst[3];
00496 double latticesize[3][4];
00497 int _TORSIONSIM;
00498 double torquespec[3];
00499 double _TORQUE, *_TORQUE_IND;
00500 int _BENDSIM;
00501 double bendspec[4];
00502 double _BENDMOMENT, *_BENDMOMENT_IND;
00503 Vector3 _P_COM, _F_COM;
00504 double _PTHETA_COM;
00505
00506
00507 double input[20000];
00508 double output_dat[2000];
00509 char output_str[10000];
00510 char output_fmt[10000];
00511 class CNFile initcn,intercn,FFScn,finalcn;
00512 class AVGCNFile avgcn;
00513 class PropFile pf;
00514 char incnfile[200], finalcnfile[200];
00515 char intercnfile[200];
00516 char FFScnfile[200];
00517 char intercfgfile[200];
00518 char outpropfile[200];
00519 char myname[200];
00520 char potfile[100];
00521 char command[MAXCMDLEN]; int ncom;
00522 int savecn, savecnfreq;
00523 int savecfg, savecfgfreq, savecfgcount;
00524 int saveprop, savepropfreq;
00525 int printfreq;
00526 int filecounter;
00527 int FFSfilecounter;
00528 int allocmultiple;
00529 int writevelocity;
00530 int writeall;
00531 int zipfiles;
00532 int fixedatomenergypartition;
00533
00534
00535 char fortranpath[100], fortranexe[100];
00536
00537
00538 char atomeyepath[100], atomeyeexe[100];
00539 int atomeyerepeat[4];
00540
00541
00542 class POSCARFile initposcar,finalposcar;
00543
00544
00545 class LAMMPSFile initlammps,finallammps;
00546
00547
00548 class MDCASKconFile initmdcaskcon,finalmdcaskcon;
00549 class MDCASKinputFile initmdcaskinput,finalmdcaskinput;
00550 char MDCASKpot[50];
00551
00552
00553 YWindow *win;
00554
00555 int win_width, win_height;
00556 double rotateangles[5];
00557 int plotfreq;
00558 double atomradius[MAXSPECIES];
00559 double bondradius, bondlength;
00560
00561 char atomcolor[MAXSPECIES][30];
00562 char bondcolor[30];
00563 char fixatomcolor[30];
00564 char highlightcolor[30];
00565 char backgroundcolor[30];
00566 char colornames[MAXCOLORS][30];
00567 unsigned colors[MAXCOLORS+15];
00568
00569 int plot_highlight_atoms[10000];
00570 double plot_limits[10];
00571 int plot_atom_info;
00572 int plot_map_pbc;
00573 double plot_color_windows[100];
00574 double plot_color_bar[10];
00575 int plot_color_axis;
00576
00577 int autowritegiffreq;
00578 double *color_ind;
00579 int NCS;
00580 int coloratoms;
00581
00582
00583
00584 MDFrame(): _SAVEMEMORY(0),_NP(0),_NP0(0),_NIMAGES(0),_NPfree(0),_NPfixed(0),
00585
00586 _R(0),_SR(0),_SRA(0),_VR(0),_VSR(0),_F(0),_R0(0),_Fext(0),_ENABLE_FEXT(0),
00587
00588 fixed(0),species(0),group(0),nspecies(1),
00589 _EPOT(0),_EPOT_IND(0),_EPOT_RMV(0),_EPOT_BOX(0),_EPOT0(0),_EPOT0_ext(0),_TOPOL(0),
00590
00591
00592 _ESTRAIN(0),_KATOM(0),_KBOX(0),_WALLMASS(1),
00593 _TIMESTEP(1e-3),_TDES(0),_T(0),_DOUBLET(0),
00594 _ATOMTCPL(100),_BOXTCPL(100),_BOXDAMP(0),
00595 zeta(0),zetav(0),zetaa(0),vt2(0.25),_HELM(0),_HELMP(0),
00596
00597 applyshear(0),
00598 forcemul(1), runavgposition(0),
00599
00600
00601 _RLIST(0),_SKIN(0),_NIC(100),_current_NIC(0),_NNM(60),_current_NNM(0),nn(0),nindex(0),
00602 link_head(0),link_list(0),
00603 celllist(0), cell_mem(0), nindex_mem(0), firsttime(true),
00604 rc_plot(0), _NNM_plot(4), nn_plot(0), nindex_plot(0), nindex_plot_mem(0),
00605
00606
00607 s2(0),s3(0),s4(0),s5(0),s2real(0),
00608 zeta2(0),zeta3(0),zeta4(0),zeta5(0),
00609 npold(0),
00610
00611
00612 NHChainLen(2),
00613
00614
00615 _TOTPRESSURE(0),_EXTSTRESSMUL(1),_EXTPRESSADD(0),_VACUUMRATIO(0),_Dexx(0),
00616
00617
00618 conj_itmax(1000),conj_fevalmax(10000),conj_fixbox(1),
00619 conj_fixshape(0),conj_fixatoms(0),conj_step(0),conj_ier(0),conj_fixdir(0),
00620 conj_dfpred(1e-3),conj_f(0),conj_ftol(1e-8),conj_g2res(0),conj_space(0),
00621 _HPRECOND(1),_XPRECOND(1),_YPRECOND(1),_ZPRECOND(1),
00622
00623
00624 constrainS(0),constrain_dist(0),
00625
00626
00627 _constrainedMD(0),
00628
00629
00630 totalsteps(100), equilsteps(0), curstep(0), step0(0), continue_curstep(0),
00631 implementation_type(0), algorithm_id(0),
00632
00633
00634 MC_atom(0),MC_accept(0),MC_accept_tot(0),
00635 MC_dV_freq(1), MC_dN_freq(1), MC_accept_ratio(0), MC_dVmax(0.1), MC_dfrac(0.1),
00636 MC_P_ext(0), MC_mu_ext(0), MC_Lambda3(0), MC_fracatom(1),
00637
00638
00639 _LAMBDA1(1),dEdlambda(0),dlambdadt(0),_ECOH(0),_WTOT(0),_WAVG(0),
00640 _ENABLE_SWITCH(0), _SWITCHFREQ(1),
00641 _RANDSEED(12345),_CHAINLENGTH(0),_SWITCHFUNC(0),_REFPOTENTIAL(0),
00642 heslen(0), hesind(0), hes(0),
00643
00644
00645 _ECSPRING(0),
00646 _I12_RC(0), _I12_SIGMA(0), _I12_EPSILON(0),
00647 _GAUSS_RC(0), _GAUSS_SIGMA(0), _GAUSS_EPSILON(0),
00648
00649
00650 _SR1(0),_SR2(0),_SR3(0),_Rc(0),_Fc(0),_nebinterp(0),
00651 readparallelnebcn(0),
00652
00653
00654 _QLM(0),_QL(0),_Lam_array(0),_Lam_check(0), L_for_QLM(0),
00655 N_solid_P(0),N_skin_P(0),N_lgst_cluster(0),Rc_for_QLM(0),
00656 QLM_cutoff(0),QLM_mark(0), QLM_solid(0), N_cluster_temp(0),
00657 N_lgst_index(0), N_lgst_skin(0), N_lgst_skin_index(0), wSKIN(0),
00658 saveFFScn(0), FFSoption(0), FFSpruning(0), FFScn_weight(1),
00659 FFS_Pp(0), FFS0_check(1), FFS_i(0), FFS_i_plus(0),
00660 FFS_i_minus(0),
00661
00662
00663 _F_Ewald(0), _F_Ewald_Real(0), _F_Ewald_Rec(0),
00664 _EPOT_IND_Ewald(0), _EPOT_IND_Ewald_Real(0), _EPOT_IND_Ewald_Rec(0),
00665 Ewald_CE_or_PME(0),
00666 Ewald_option_Alpha(0),
00667 Ewald_Rcut(9),
00668 Ewald_precision(4.2),
00669 Ewald_time_ratio(3.6),
00670 _EPOT_Ewald(0), _EPOT_Ewald_Real(0),
00671 _EPOT_Ewald_Rec(0), _EPOT_Ewald_Self(0),
00672 Ewald_Alpha(0), Ewald_qSQRsum(0),
00673 Ewald_H_L1(0), Ewald_H_L2(0), Ewald_H_L3(0), Ewald_cell_V(0),
00674
00675 CE_MKV(0), CE_nKV(0),
00676 CE_Mka(0), CE_Mkb(0), CE_Mkc(0),
00677 CE_Kc(0),
00678 CE_KV(0),
00679 CE_sc_axby(0), CE_sckk(0),
00680 CE_scx(0), CE_scy(0), CE_scz(0),
00681 CE_sREAL(0), CE_sREC(0), CE_eREAL(0), CE_eREC(0),
00682 CE_iREAL(0), CE_iREC(0), CE_tREAL(0), CE_tREC(0),
00683
00684
00685 PME_bsp_n(8),
00686 PME_K1(64), PME_K2(64), PME_K3(64), PME_K3S(0),
00687 PME_K23(0), PME_K123(0), PME_K23S(0), PME_K123S(0),
00688 PME_K1d(0), PME_K2d(0), PME_K3d(0), PME_K123d(0),
00689 _UR(0),
00690
00691 PME_B(0), PME_C(0), PME_BC(0), PME_Q(0), PME_CONV(0), PME_IQ(0),
00692 PME_bsp_Mk(0), PME_bsp_fac(0),
00693 PME_m1s(0), PME_m2s(0), PME_m3s(0),
00694 PME_m1(0), PME_m2(0), PME_m3(0),
00695 PME_m1mod(0), PME_m2mod(0), PME_m3mod(0),
00696
00697 PME_x1(0), PME_x2(0), PME_x3(0),
00698 PME_MU1(0), PME_MU2(0), PME_MU3(0),
00699 PME_d1MU1(0), PME_d1MU2(0), PME_d1MU3(0),
00700 PME_d2MU1(0), PME_d2MU2(0), PME_d2MU3(0),
00701
00702 PME_sREC(0), PME_eREC(0), PME_iREC(0), PME_tREC(0),
00703
00704
00705 storedr(0),
00706
00707
00708 _TORSIONSIM(0),_TORQUE(0),
00709
00710
00711 _BENDSIM(0), _BENDMOMENT(0),
00712
00713
00714 _PTHETA_COM(0),
00715
00716
00717 initcn(AUXFile::BLOCK),intercn(AUXFile::SERIES),
00718 FFScn(AUXFile::SERIES),
00719 finalcn(AUXFile::BLOCK),avgcn(AUXFile::BLOCK),
00720 pf(AUXFile::ENTRIES),
00721 ncom(0),savecn(0),savecnfreq(100),savecfg(0),
00722 savecfgfreq(100),savecfgcount(1),
00723 saveprop(0),savepropfreq(100),
00724 printfreq(100),filecounter(1),FFSfilecounter(1),
00725 allocmultiple(1),writevelocity(0),writeall(0),
00726 zipfiles(0),fixedatomenergypartition(0),
00727
00728
00729 initposcar(AUXFile::BLOCK),finalposcar(AUXFile::BLOCK),
00730
00731
00732 initlammps(AUXFile::BLOCK),finallammps(AUXFile::BLOCK),
00733
00734
00735 initmdcaskcon(AUXFile::BLOCK),finalmdcaskcon(AUXFile::BLOCK),
00736 initmdcaskinput(AUXFile::BLOCK),finalmdcaskinput(AUXFile::BLOCK),
00737
00738
00739 win(0),win_width(350),win_height(350),
00740 plotfreq(1),bondradius(0.1),bondlength(0),plot_atom_info(1),plot_map_pbc(0),
00741 plot_color_axis(0),autowritegiffreq(0),color_ind(0),NCS(12),coloratoms(0)
00742
00743 {
00744
00745 input[0]=0;
00746 output_str[0]=0;
00747 output_fmt[0]=0;
00748 _ATOMMASS[0]=1;
00749
00750
00751 latticeconst[0]=latticeconst[1]=latticeconst[2]=1.0;
00752 sprintf(crystalstructure,"simple-cubic");
00753
00754
00755 MC_switchoffatoms[0]=0;
00756
00757
00758 plot_highlight_atoms[0]=0;
00759 plot_limits[0]=0;
00760 plot_color_windows[0]=0;
00761 plot_color_bar[0]=0;
00762
00763
00764 };
00765
00766 virtual ~MDFrame() { delete(win); }
00767
00768
00769 virtual void initparser();
00770 virtual int exec(char *name);
00771 virtual void initvars();
00772 void runcommand();
00773 #ifdef _USETCL
00774 virtual int Tcl_AppInit(Tcl_Interp *interp);
00775 #endif
00776
00777
00778 void SHtoR();
00779 void RHtoS();
00780 void RtoR0();
00781 void R0toR();
00782 void clearR0();
00783 bool Bond(int I, int J) const;
00784
00785 virtual void Alloc();
00786
00787
00788 virtual void call_potential();
00789 virtual void potential();
00790 virtual void potential_energyonly();
00791 virtual double potential_energyonly(int iatom);
00792 void ECpotential();
00793 void ECpotential_energyonly();
00794 double ECpotential_energyonly(int iatom);
00795 void HApotential();
00796 void HApotential_energyonly();
00797 void I12potential_energyonly();
00798 void I12potential();
00799 void GAUSSpotential();
00800 void SWITCHpotential_energyonly(double lambda);
00801 void SWITCHpotential(double lambda);
00802 virtual void SWITCHpotential_user(double lambda);
00803 virtual void SWITCHpotential_user_energyonly(double lambda);
00804 double SWITCH_Find_Lambda();
00805 void eval_insertparticle();
00806 void eval_removeparticle();
00807
00808
00809 virtual void NbrList_reconstruct(int iatom=-1);
00810 void NbrList_reconstruct_use_cell_list(int iatom=-1);
00811 void NbrList_reconstruct_use_link_list(int iatom=-1);
00812
00813 void NbrList_print();
00814 void NbrList_refresh();
00815 bool NbrList_needrefresh();
00816 void NbrList_init(int, int);
00817 void NbrList_free();
00818
00819 void NbrList_initlinklist(int);
00820 void NbrList_freelinklist();
00821
00822 void NbrList_initcell(int,int,int,int);
00823 void NbrList_freecell();
00824
00825 void NbrListPlot_reconstruct();
00826 void NbrListPlot_init(int,int);
00827 #define refreshneighborlist NbrList_refresh
00828
00829
00830 void NVE_Gear6();
00831 void NVT_Gear6();
00832 void NVTC_Gear6();
00833 void NPH_Gear6();
00834 void NPT_Gear6();
00835 void NPTC_Gear6();
00836 void Gear6_init();
00837 void VVerlet_Get_s2();
00838 void VVerlet_Get_h2();
00839 void VVerlet_Get_Tinst();
00840 void VVerlet_NHCINT();
00841
00842 void NVE_VVerlet(int);
00843 void NVT_VVerlet_Implicit(int);
00844 void NVT_VVerlet_Explicit_1(int);
00845 void NVT_VVerlet_Explicit_2(int);
00846 void NVTC_VVerlet_Explicit(int);
00847 void NPH_VVerlet(int);
00848 void NPH_VVerlet_Explicit_1(int);
00849
00850 void NPT_VVerlet_Implicit(int);
00851 void NPT_VVerlet_Explicit_1(int);
00852 void NPT_VVerlet_Explicit_2(int);
00853
00854
00855 int applyconstraint();
00856 int relax();
00857 int constrainedrelax();
00858 void relax_by_group(double *);
00859 static void potential_wrapper(int *n,double x[],double *f,double df[]);
00860 static void potential_wrapper_c(int n,double x[],double *f,double df[]);
00861 static void cstr_potential_wrapper(int *n,double x[],double *f,double df[]);
00862 static void cstr_potential_wrapper_c(int n,double x[],double *f,double df[]);
00863 void strelax();
00864
00865
00866 virtual void integrator();
00867
00868 virtual void run();
00869 virtual void calcprop();
00870 virtual void calcoutput();
00871 void printResult();
00872 void calDVIRIALDexx();
00873 void calcentralsymmetry();
00874 void caldisregistry();
00875 void calHessian();
00876 void readHessian();
00877 void calModeHessian();
00878 void calphonondisp();
00879 void calmisfit();
00880 void calmisfit2();
00881 void testpotential();
00882 void findcore();
00883 void initvelocity();
00884 void randomposition();
00885
00886 void perturbevelocity();
00887 void MCperturbevelocity();
00888 void multiplyvelocity();
00889 void step();
00890 void eval();
00891 void multieval();
00892
00893
00894 int runMC();
00895 int runTAMC();
00896 int MCstep();
00897 int MCstep_moveatom();
00898 int MCstep_dV();
00899 int MCstep_dN();
00900 int MCstep_fracatom();
00901 int MCstep_moveatom_fracatom();
00902 int MCstep_dV_fracatom();
00903 int MCstep_dN_fracatom();
00904 int runMCSWITCH();
00905 int MCSWITCHstep(double lambda);
00906 int runMDSWITCH();
00907
00908
00909 void AllocChain();
00910 void caldscom12();
00911 void initRchain();
00912 int readRchain();
00913 int writeRchain();
00914 #ifdef _STRINGMETHOD
00915 void runstringmethod();
00916 #endif
00917 void nebrelax();
00918 void annealpath();
00919 void cutpath();
00920 int statedistance();
00921 int interpCN(double s);
00922 void copyRchaintoCN(int j);
00923 void copyCNtoRchain(int j);
00924 void moveRchain(int, int);
00925
00926
00927 void calcrystalorder();
00928 void allocQLM();
00929 void assign_Lam();
00930 void DFS(int,int,double);
00931 void DFS1(int,int,double,double);
00932 int FFSprocess();
00933
00934
00935 void Ewald_init();
00936 void CE();
00937 void CE_Real();
00938 void CE_Rec();
00939 void CE_init();
00940 void CE_clear();
00941 void CE_enumKV();
00942 void CE_fillSinCosTables();
00943
00944
00945 void PME();
00946 void PME_Rec();
00947 void PME_init();
00948 void PME_clear();
00949 void PME_cal_bsp_fac();
00950 void PME_cal_bsp_Mk();
00951 double PME_cal_bsp_Mu(int n, double u);
00952 void PME_cal_bsp_Bm(int mi, int Ki);
00953 double PME_cal_bsp_Cm(int m1, int m2, int m3);
00954
00955
00956 void makecrystal();
00957 void makecut();
00958 void makedipole();
00959 void makedislocation();
00960 void makecylinder();
00961 void setfixbufferatoms();
00962 void makedislcylinder();
00963
00964 void makedisloop();
00965 void calloopdisp
00966 (Vector3 *,double,double,Vector3 *,Vector3 *,Vector3 *);
00967 void makegrainboundary();
00968 void makewave();
00969 void maketorquehandle();
00970 void removetorquehandle();
00971 void makebendhandle();
00972 void copytorqueatoms();
00973 void copybendatoms();
00974
00975 void scaleH();
00976 void setH();
00977 void saveH();
00978 void restoreH();
00979 void scaleVel();
00980
00981 void shiftbox();
00982 void redefinepbc();
00983 void applystrain();
00984 void extendbox();
00985
00986 void cutslice();
00987 void splicecn();
00988 void cutpastecn();
00989
00990 void setconfig1();
00991 void setconfig2();
00992 void switchconfig();
00993 void copytoconfig1(int);
00994 void copytoconfig2(int);
00995 void replacefreeatom();
00996 void relabelatom();
00997
00998 void moveatom();
00999 void movegroup();
01000 void setgroupcomvel();
01001 void addtorque();
01002 void addbend();
01003 void printatoms_in_sphere();
01004 void pbcshiftatom();
01005
01006 void fixatoms_by_ID();
01007 void fixatoms_by_position();
01008 void fixatoms_by_group(double *);
01009 void fixatoms_by_species(double *);
01010 void fixatoms_by_pos_topol();
01011 void fixallatoms();
01012 void freeallatoms();
01013 void reversefixedatoms();
01014 void constrain_fixedatoms();
01015 void fix_constrainedatoms();
01016
01017 void setfixedatomsspecies();
01018 void setfixedatomsgroup();
01019 void reversespecies();
01020 void movefixedatoms();
01021 void removefixedatoms();
01022 void markremovefixedatoms();
01023 void removeellipsoid();
01024 void removerectbox();
01025 void removeoverlapatoms();
01026 void findcenterofmass(class Vector3 *);
01027 void translate_com();
01028 void rotate_com();
01029
01030 void clearFext();
01031 void addFext_to_group();
01032
01033
01034 virtual void saveintercn(int);
01035 int readcn();
01036 int readPOSCAR();
01037 int readMDCASK();
01038 int readMDCASKJAIME();
01039 int readXYZ();
01040 int readLAMMPS();
01041 int convertXDATCAR();
01042 int setfilecounter();
01043 int setFFSfilecounter();
01044 int openintercnfile();
01045 int openFFScnfile();
01046 int openpropfile();
01047 int closepropfile();
01048
01049 int writefinalcnfile(int zip=1,bool bg=true);
01050 int writeavgcnfile(int zip=1,bool bg=true);
01051 int writePOSCAR();
01052 int writeLAMMPS();
01053 int writeMDCASK();
01054 void writePINYMD(char *fname);
01055 int writeintercnfile(int zip=1,bool bg=false);
01056 int writeFFScnfile(int zip=1,bool bg=false);
01057
01058
01059 void writefortraninifile(char *fname);
01060 void fortranrelax();
01061
01062
01063 virtual void writeatomeyecfgfile(char *fname);
01064 void convertCNtoCFG();
01065 void atomeye();
01066 void writepovray(char *fname);
01067 void writeMDCASKXYZ(char *fname);
01068 void writeRASMOLXYZ(char *fname);
01069 void readRASMOLXYZ(char *fname);
01070 void writeatomtv(char *fname);
01071
01072
01073 void writeENERGY(char *fname);
01074 void writeFORCE(char *fname);
01075 void writePOSITION(char *fname);
01076 void GnuPlotHistogram();
01077
01078
01079 virtual void winplot();
01080 virtual void winplot(int);
01081 virtual void openwin();
01082 virtual void plot();
01083 int openwindow(int w,int h,const char *n);
01084 void closewindow();
01085 void wintogglepause();
01086 void alloccolors();
01087 void alloccolorsX();
01088 void rotate();
01089 void saverot();
01090
01091 };
01092
01093
01094
01095 #ifdef _USETCL
01096
01097 int MD_Cmd(ClientData clientData,Tcl_Interp *interp,int argc, const char *argv[]);
01098 int MD_SetVar(ClientData clientData,Tcl_Interp *interp,int argc, const char *argv[]);
01099 int MD_GetVar(ClientData clientData,Tcl_Interp *interp,int argc, const char *argv[]);
01100 int Tcl_Main_Wrapper(int argc, char *argv[]);
01101
01102 #define Tcl_Parser_Init(sim) \
01103 int Tcl_AppInit(Tcl_Interp *interp) \
01104 { \
01105 return sim.Tcl_AppInit(interp); \
01106 } \
01107 \
01108 int MD_Cmd(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])\
01109 { \
01110 FILE *istream, *ostream; int mypipe[2]; \
01111 \
01112 if (pipe (mypipe)) \
01113 { \
01114 fprintf (stderr, "Pipe failed.\n"); \
01115 return EXIT_FAILURE; \
01116 } \
01117 istream = fdopen(mypipe[0], "r"); \
01118 ostream = fdopen(mypipe[1], "w"); \
01119 for(int i=1;i<argc;i++) \
01120 fprintf(ostream,"%s ",(char *)argv[i]); \
01121 fprintf(ostream,"\n"); \
01122 fclose(ostream); \
01123 sim.parse_line(istream); \
01124 fclose(istream); \
01125 return TCL_OK; \
01126 } \
01127 \
01128 int MD_SetVar(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])\
01129 { \
01130 int i, curn; \
01131 curn = sim.identify(argv[1]); \
01132 if(curn<0) \
01133 { \
01134 WARNING("Unrecognized variable "<<argv[1]); \
01135 return TCL_OK; \
01136 } \
01137 for(i=2;i<argc;i++) \
01138 { \
01139 switch(sim.vartype[curn]) \
01140 { \
01141 case(INT): sscanf(argv[i],"%d",(int *)sim.varptr[curn]+i-2+sim.shift); break; \
01142 case(LONG): sscanf(argv[i],"%ld",(long *)sim.varptr[curn]+i-2+sim.shift); break;\
01143 case(DOUBLE): sscanf(argv[i],"%lf",(double *)sim.varptr[curn]+i-2+sim.shift); break;\
01144 case(STRING): strcpy((char *)sim.varptr[curn]+i-2+sim.shift,argv[i]); break; \
01145 default: FATAL("unknown vartype ("<<sim.vartype[curn]<<")"); \
01146 } \
01147 } \
01148 return TCL_OK; \
01149 } \
01150 \
01151 int MD_GetVar(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[])\
01152 { \
01153 int i, curn, offset; char buf[1000]; \
01154 curn = sim.identify(argv[1]); \
01155 if(curn<0) \
01156 { \
01157 WARNING("Unrecognized variable "<<argv[1]); \
01158 return TCL_OK; \
01159 } \
01160 for(i=1;i<argc;i++) \
01161 { \
01162 if(i==1) offset=0; \
01163 else sscanf(argv[i],"%d",&offset); \
01164 if(i>2) sprintf(buf," "); \
01165 switch(sim.vartype[curn]) \
01166 { \
01167 case(INT): sprintf(buf,"%d",*((int *)sim.varptr[curn]+offset+sim.shift)); break; \
01168 case(LONG): sprintf(buf,"%ld",*((long *)sim.varptr[curn]+offset+sim.shift)); break;\
01169 case(DOUBLE): sprintf(buf,"%.16g",*((double *)sim.varptr[curn]+offset+sim.shift)); break;\
01170 case(STRING): sprintf(buf,"%s",(char *)sim.varptr[curn]+offset+sim.shift); break;\
01171 default: FATAL("unknown vartype ("<<sim.vartype[curn]<<")"); \
01172 } \
01173 } \
01174 Tcl_SetResult(interp, buf, TCL_VOLATILE); \
01175 return TCL_OK; \
01176 }
01177
01178 #endif
01179
01180 #endif //_MD_H