Lemina
A molecular dynamics package for network, granular material and point particles with a range of interaction potential.
 
Loading...
Searching...
No Matches
EvalSpacetimeCorr.c
Go to the documentation of this file.
1/*
2 * This file is part of Lamina.
3 *
4 * Lamina is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Lamina is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Lamina. If not, see <https://www.gnu.org/licenses/>.
16
17 Copyright (C) 2025 Harish Charan, University of Durham, UK
18
19 */
20
21
22#include<stdio.h>
23#include<math.h>
24#include"global.h"
25
27 real cosV=0., cosV0=0., cosV1=0., cosV2=0., sinV=0., sinV1=0., sinV2=0.;
28 real COSA, SINA, COSV, SINV;
29 int j, m, n, nb, ni, nv;
30 real kMin = 2. * M_PI / region[1];
31 real kMax = M_PI;
32 real deltaK = (kMax - kMin) / nFunCorr;
33
34 for (j = 1; j <= 2*nFunCorr; j++)
35 cfVal[j] = 0.;
36
37 for (n = 1; n <= nAtom; n++){
38 j = 1;
39 COSA = cos(kMin*rx[n]);
40 SINA = sin(kMin*rx[n]);
41 for (m = 1; m <= nFunCorr; m++){
42 if(m == 1){
43 cosV = cos(deltaK*rx[n]);
44 sinV = sin(deltaK*rx[n]);
45 cosV0 = cosV;
46 }else if(m == 2){
47 cosV1 = cosV;
48 sinV1 = sinV;
49 cosV = 2.*cosV0*cosV1-1;
50 sinV = 2.*cosV0*sinV1;
51 }else{
52 cosV2 = cosV1;
53 sinV2 = sinV1;
54 cosV1 = cosV;
55 sinV1 = sinV;
56 cosV = 2.*cosV0*cosV1-cosV2;
57 sinV = 2.*cosV0*sinV1-sinV2;
58 }
59 COSV = COSA*cosV - SINA*sinV;
60 SINV = SINA*cosV + COSA*sinV;
61 cfVal[j] += COSV;
62 cfVal[j+1] += SINV;
63 j += 2;
64 }
65 }
66
67 for (nb = 1; nb <= nBuffCorr; nb++){
68 indexCorr[nb] += 1;
69 if (indexCorr[nb] <= 0) continue;
70 ni = nFunCorr * (indexCorr[nb] - 1);
71 if (indexCorr[nb] == 1){
72 for (j = 1; j <= 2*nFunCorr; j++)
73 cfOrg[nb][j] = cfVal[j];
74 }
75
76 for (j = 1; j <= nFunCorr; j++)
77 spacetimeCorr[nb][ni + j] = 0.;
78
79 j = 1;
80 for (m = 1; m <= nFunCorr; m++){
81 nv = m + ni;
82 spacetimeCorr[nb][nv] += cfVal[j] * cfOrg[nb][j] + cfVal[j + 1] * cfOrg[nb][j + 1];
83 j += 2;
84 }
85
86 }
87
88 // ACCUMULATE SPACETIME CORRELATIONS
89 for (nb = 1; nb <= nBuffCorr; nb++){
90 if (indexCorr[nb] == nValCorr){
91 for (j = 1; j <= nFunCorr*nValCorr; j++)
92 spacetimeCorrAv[j] += spacetimeCorr[nb][j];
93 indexCorr[nb] = 0.;
94 countCorrAv ++;
96 for (j = 1; j <= nFunCorr*nValCorr; j++)
98 fprintf(fpdnsty,"NDIM %d\n", NDIM);
99 fprintf(fpdnsty,"nAtom %d\n", nAtom);
100 fprintf(fpdnsty,"region %lf\n", region[1]);
101 fprintf(fpdnsty,"nFunCorr %d\n", nFunCorr);
102 fprintf(fpdnsty,"limitCorrAv %d\n", limitCorrAv);
103 fprintf(fpdnsty,"stepCorr %d\n", stepCorr);
104 fprintf(fpdnsty,"nValCorr %d\n", nValCorr);
105 fprintf(fpdnsty,"deltaT %lf\n", deltaT);
106 real tVal;
107 for (n = 1; n <= nValCorr; n++){
108 tVal = (n-1)*stepCorr*deltaT;
109 fprintf (fpdnsty, "%e\t", tVal);
110 int nn = nFunCorr*(n-1);
111 for (j = 1; j <= nFunCorr; j ++)
112 fprintf (fpdnsty, "%e\t", spacetimeCorrAv[nn + j]);
113 fprintf (fpdnsty, "\n");
114 }
115
116 countCorrAv = 0.;
117 for (j = 1; j <= nFunCorr*nValCorr; j++)
118 spacetimeCorrAv[j] = 0.;
119 }
120 }
121 }
122}
void EvalSpacetimeCorr()
int limitCorrAv
Definition global.h:95
int nAtom
Definition global.h:24
double real
Definition global.h:11
int countCorrAv
Definition global.h:95
int nValCorr
Definition global.h:95
double * spacetimeCorrAv
Definition global.h:94
#define NDIM
Definition global.h:13
FILE * fpdnsty
double region[2+1]
int stepCorr
Definition global.h:95
double ** spacetimeCorr
Definition global.h:94
int * indexCorr
double deltaT
Definition global.h:20
double * rx
int nBuffCorr
Definition global.h:95
double ** cfOrg
double * cfVal
Definition global.h:94
int nFunCorr
Definition global.h:95