#include "dump2analysis.h" /* DOCUMENT */ /* -m gr */ /* lammpstrjから2原子間の動径分布関数を計算する */ /* またカットオフ距離内の平均結合距離を求める */ /* A原子(-a, -x, -s)とB原子(-c, -z, -u)を指定する。 */ /* --rmaxは動径分布関数を計算する最大距離 default:10.005 */ /* --rminは動径分布関数を計算する最小距離 default:0.01 */ /* --drは動径分布関数を計算する刻み距離 default:0.01 */ /* --rcutは結合距離を計算するカットオフ default:2.3 */ void ErrorGr(){ printf("Required arguments atoms A and atoms B\n"); printf("(-a, -x, -s) atom A\n"); printf("(-b, -y, -t) atom B\n"); printf("------------------------------------------------------------\n"); printf("Optional arguments for Gr analysis:\n"); printf("--dr distance step for g(r) [0.01]\n"); printf("--rmax maximum distance for g(r) [10.005]\n"); printf("--rmin minimum distance for g(r) [0.005]\n"); printf("--rcut cut-off for alculation of mean distance [2.3]\n"); printf("------------------------------------------------------------\n"); printf("Example:\n"); printf("dump2analysis -m gr -x Si -y O -i hoge.lammpstrj -o hoge.gr\n"); exit(0); } void OutputGr(PARAM *p, double *gr, double *cn, ATOMS *a, ATOMS *b, double ave, double std, int pairs){ int i, RDATA; double rp, rcn=0; FILE *fp; RDATA = floor((RMAX-RMIN)/DR); fp = fopen(p->outfile, "w"); fprintf(fp, "# Total step: %d\n", p->steps); /* fprintf(fp, "# atom-A:"); */ /* for(i=0; iatoms; i++) */ /* fprintf(fp, " %s(%d)", a->elem[i], a->id[i]); */ /* fprintf(fp, "\n"); */ /* fprintf(fp, "# atom-B:"); */ /* for(i=0; iatoms; i++) */ /* fprintf(fp, " %s(%d)", b->elem[i], b->id[i]); */ /* fprintf(fp, "\n"); */ fprintf(fp, "# (Rmin, Rmax, dr)=(%g, %g, %g)\n", RMIN, RMAX, DR); fprintf(fp, "# RDATA=%d\n", RDATA); fprintf(fp, "\n"); fprintf(fp, "# Total pairs: %d\n", pairs); fprintf(fp, "# Rcut : %lf\n", RCUT); fprintf(fp, "# distance: %lf +/- %lf\n", ave, std); fprintf(fp, "# %10s %12s %12s\n", "r", "g(r)", "cn(r)"); fprintf(fp, "%12g %12g %12g\n", 0.0, 0.0, 0.0); for(i=0; isteps); fprintf(fp, "%12g ", rcn/(double)p->steps); fprintf(fp, "\n"); } fclose(fp); } void EstimateGr(PARAM *param){ FILE *f; HEAD head; int i, j, k, l, p, s, RDATA; double *gr, *cn, *cr; double volume, bunbo, sflag = 0.0; double xa, ya, za, xb, yb, zb, xp, yp, zp, r; double ave = 0.0, std = 0.0, *d = NULL; int rp, pairs=0; ATOMS a, b; if (ArgCheckInputOutput(param) != 0) ErrorGr(); SetAtomsSteps(param); if (CheckArgAtomSelect(param) != 3) ErrorGr(); Allocate(&a, param->atoms); Allocate(&b, param->atoms); f = fopen(param->infile, "r"); RDATA = floor((RMAX-RMIN)/DR); gr = malloc(sizeof(double)*RDATA); cn = malloc(sizeof(double)*RDATA); cr = malloc(sizeof(double)*RDATA); /* grの計算 */ for (i=0; isteps; s++){ if (s%10 == 0) { printf("Calculating Gr step: %d\r", s); fflush(stdout); } /* 初期化 */ for (i=0; iatoms); Deallocate(&b, param->atoms); /* 平均値の計算 */ for (i=0; i