/*** Last modified on 10/21/2010 by avv/cfdrc ***/ /*** New GetAtomlist_mod was added to elimane needs to have Atomlist file ***/ #include #include #include #define Atomlist "config_2x2x2.out" #define Cutoff "Cutoff.dic" #define Snapshots "bonds.reax.cl20" #define Output1 "fra.out" #define Output2 "mol.out" #define Output3 "num.out" #define Output4 "dipol.out" #define Output5 "vibtemp.out" #define Output6 "conc.out" #define MaxNumBonds 10 //Max Number of bonds per atom #define MaxMolTypes 80000 //Max Number of molecule types #define Natomtypes 4 //C,H,O,N #define Hydrogen 1 #define Carbon 0 #define Nitrogen 3 #define Oxygen 2 void FileOpenError(); void Allocation(); int AtomIndicator(); int Natom,Nmolecule;//total numbers of atoms and molecules int Nmoltype=0;//number of species int *Atomdic;//this array stores atom type accessible by atom id-1. int *MolName;//an array that stores number of atoms of each type for each molecule by using counters of Natomtypes*imoleculetypes+atomtype so if H2 is the second molecule entry the array will have 4=0, 5=2, 6=0, 7=0. int *MolType;//array with the same info as MolName but accessed by Nmoltype, not molecule id. int *Mol;//an array that stores the molecule id for each atom int *NMol;//an array that stores the number of molecules of this species for this frame double *Netc;//an array that stores charge double Mass[Natomtypes]; double *rx,*ry,*rz,*Charge; double *vx,*vy,*vz; double COdic[Natomtypes][Natomtypes]; double latc_x[3],latc_y[3],latc_z[3];//lattice parameters of the box read from config.out double Ilatc_x[3],Ilatc_y[3],Ilatc_z[3];//normalized box lengths double Origin[3];//origin coordinates of the box FILE *trj,*dpol,*vtemp,*conc; main() { void GetAtomlist(); void GetAtomlist_mod(); void GetCOdict(); void AnalyzeTrajectory(); void PostProcess(); GetAtomlist_mod(Snapshots); GetCOdict(Cutoff); AnalyzeTrajectory(Snapshots,Output3); PostProcess(Output1,Output2,Output3); } void GetAtomlist_mod(char *name) { /*This subroutine reads the bonds.petn file to set the number of atoms. It also checks that a full frame exists because it loops over the first frame to populate the Atomdic with the proper type for each atom id.*/ FILE *fp; char buffer[1000]; int i,j, Nlink, iatom, itemp, id; double BO,dtemp;//BO is bond order fp=fopen(name,"r"); FileOpenError(fp,name); while(fscanf(fp,"%s",buffer)!=EOF) { if(strcmp(buffer,"particles")==0) { fscanf(fp,"%d",&Natom); printf("# of atoms : %d\n",Natom); Allocation(); } if(strcmp(buffer,"q")==0) { for(i=0;iCOdic[iatomtype][jatomtype]) { if(Molid!=MolTemp[iatom]) { if(MolTemp[jatom]==-1) MolTemp[jatom]=MolTemp[iatom]; else { for(k=0;k