-
Notifications
You must be signed in to change notification settings - Fork 0
/
lmp2sqt.h
232 lines (212 loc) · 6.37 KB
/
lmp2sqt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*!
* \file lmp2sqt.h
* \brief
*
* Evaluate intermediate scattering function from lammps dump files.
* \f$F_s(q,t) \f$ (1.1) self intermediate scattering function
* TAG name ptl1
*
* \author KIM Hyeok (kh), [email protected]
*
* \internal
* Created: 2017- 05- 29
* Revision: 1
* Compiler: gcc
* Organization: Konkuk University
* Copyright: Copyright (c) 2017, KIM Hyeok
*
* This source code is released for free distribution under the terms of the
* GNU General Public License as published by the Free Software Foundation.
*/
#ifndef __lmp2sqt_h__
#define __lmp2sqt_h__
/* ##### HEADER FILE INCLUDES ################################################### */
#include "common.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "snapshot.h"
#include <omp.h>
/* ##### EXPORTED TYPE DEFINITIONS ############################################## */
//typedef struct {
// real R, I;
//} Cmplx;
/*!
* move to common
* \brief struct for complex real value
*/
//typedef struct {
// real xx,xy,xz;
// real yx,yy,yz;
// real zx,zy,zz;
//} Rank2R3;
//typedef struct {
// real x,y,z;
//} VecR3;
typedef struct {
real **F_qq2, *org_rho_q1, *org_kvel_q1, *org_kmu_q1;
real **C2_v_rho, **C2_mu_rho, **C2_v_mu;
real **C2_rho_v, **C2_rho_mu, **C2_mu_v;
real **C2_v_v, **C2_mu_mu;
real **F_s_qq2, **F_d_qq2, **org_rho_s_q1 , **org_rho_d_q1 ;
VecR3 *orgR, *rTrue, *orgV, *orgMu;
real *rho_q1, *kvel_q1, *kmu_q1 ;
real **rho_s_q1, **rho_d_q1;
real *rho_s_q1_temp;
Rank2R3 orgSumVR;
Rank2R3 sumVR_ct;
real *rrCvv, *rrCmm; real *rrCvcmvcm;
// VecR3 *orgVel; real *acfVel;
Rank2R3 *rrMSR2_VR;
VecR3 *rrMSR1_R;
real *rrMSD;
real *rrMSDCM;
real *rrMQD;
int **DrTable;
int count;
int countDiff;
} TBuf;
/* ##### EXPORTED FUNCTION DECLARATIONS ######################################### */
#define ALLOC(type) type* alloc_ ## type(size_t n) { \
return (type *) malloc(sizeof(type)*n); \
}
/*!
* \def ALLOC(type)
* \brief macro for basic allocation function named alloc_(type)
*/
#define Min(a,b) ( (a<b)?(a):(b))
ALLOC(double);
ALLOC(real);
ALLOC(int);
ALLOC(Cmplx);
ALLOC(VecR3);
#define CSet(a, x, y) a.R = x, a.I = y
#define CAdd(a, b, c) a.R = b.R + c.R, a.I = b.I + c.I
#define CSub(a, b, c) a.R = b.R - c.R, a.I = b.I - c.I
#define CMul(a, b, c) a.R = b.R * c.R - b.I * c.I, a.I = b.R * c.I + b.I * c.R
#define Sqr(x) ( (x)*(x))
#define CHAR_MINUS '-'
#define CHAR_ZERO '0'’
#define NameVal(x) \
if (! strncmp (bp, #x, strlen (#x))) { \
bp += strlen (#x); \
x = strtod (bp, &bp); \
}
#define TAG 1
//#define N_AXIS (3+4+6) /*!< \brief 3d - > 3 */
#define N_AXIS (3) /*!< \brief 3d - > 3 */
#define DOF (2*(1)) /*!< \brief 2x(density+velocity+magnet) */
#define FDOF (N_AXIS*DOF) /*!< \brief memory for correlator */
#define AVDOF 1 //!< (vel,mag)*(long,trans) + density
int n_FDOF = FDOF;
int n_DOF = DOF;
int n_AVDOF = AVDOF;
enum { DEN=6, V_X=0,V_Y=1,V_Z=2, M_X=3,M_Y=4,M_Z=5,
V_LONG=0,V_TRANS=1,M_LONG=2,M_TRANS=3, AV_DEN=4} ;
enum {VXC =0, VXS, VYC, VYS, VZC, VZS,
MXC =6, MXS, MYC, MYS, MZC, MZS,
OneC=12, OneS} ; // Those are not used.
#define CSet(a,x,y) \
a.R = x, \
a.I = y
#define BUFF_LEN 1024
/* char *header[]= {"cur-long", "cur-trans", "densty"},
* *txtCorr = "space-time corr";
*/
void* unused_pointer;
int ununused_value;
long long int ll_mem_size=0;
int ErrorAllocMem=0;
#define AmountAllocMem(a, n, t) \
((long long)n* sizeof(t))
#define AmountAllocMem2(a, n1, n2, t) \
(AmountAllocMem (a, n1, t *)+ \
AmountAllocMem (a[0], (n1) * (n2), t))
#define AllocMem(a, n, t) \
a = (t *) malloc ((n) * sizeof (t)); \
if (a == NULL ) ErrorAllocMem=1; \
ll_mem_size += (long long)n* sizeof(t);
#define AllocMem2(a, n1, n2, t) \
AllocMem (a, n1, t *); \
AllocMem (a[0], (n1) * (n2), t); \
for (ununused_value = 1; ununused_value < n1; ununused_value ++) a[ununused_value] = a[ununused_value - 1] + n2;
/*!
* \def AllocMem(a, n, t)
* @param[out] a array of type t
* @param[in] n array size
* @param t type
*/
/*!
* \def AllocMem2(a, n1, n2, t)
* @param[out] a 2 dimensitional array of type t
* @param[in] n1,n2 n1 x n2 array size
* @param t type
*/
/* ##### EXPORTED DATA TYPES #################################################### */
// local Data
typedef struct {
TBuf *tBuf;
int flag_alloc,flag_alloc_more;
Snapshot* snap;
int nSkip;
} MakeSqtClass;
MakeSqtClass* classSqt;
// global data
real kVal, deltaT, rVal, g_Vol,mass;
real L ; /*!< \brief box length */
int nPtls;
/*!
* \brief for Intermediate scattering function <rho(q,t)rho(-q,0)>
*/
real **avF_qq2, **valDqt, **valGammaQT ;
real **avF_s_qq2, **avF_d_qq2;
real **StdDevF_qq2, **StdDevF_s_qq2, **StdDevF_d_qq2;
real **avC2_v_v;
real **avC2_v_rho;
real **avC2_rho_v;
real **avC2_rho_mu;
real **avC2_mu_rho;
real **avC2_mu_mu;
real **avC2_v_mu;
real **avC2_mu_v;
real *factorDr, *radius;
int countCorrAv, limitCorrAv, nCBuffer, nCSpatial, nCTime, nCSkip;
/*!
* \brief for van Hove function (globall
*/
real *rrDt;
real **avDrTable;
/*!
* \brief Accumulate and average value ( globall)
*/
real *rrMSR2_VR_Av_offdig;
real *rrMSR2_VR_Av_dig;
VecR3 *rrMSR1_R_Av;
real *rrMQDAv;
real *rrMSDAv;
real *rrMSDCMAv;
real *rrCvvAv;
real *rrCvcmvcmAv;
real *rrCmmAv;
Rank2R3 *rrMSR2_VR_Av;
/*!
* \brief openmp locker
*/
int nthreads, threadID;
omp_lock_t write_lock,read_lock;
/* ##### EXPORTED FUNCTION DECLARATIONS ######################################### */
void Init_reciprocal_space(Snapshot*);
void ZeroAvSpacetimeCorr ();
void InitSpacetimeCorr (MakeSqtClass* );
void EvalOtherInformation ();
void PrintProcess ( MakeSqtClass* );
void PrintSpacetimeCorr (FILE *fp);
void PrintSpacetimeCorrTr (FILE *fp);
void EvalSpacetimeCorr (MakeSqtClass*);
void AmountAllocArray(MakeSqtClass*);
void AllocArray(MakeSqtClass* );
void AllocMemCheck ();
void Alloc_more(MakeSqtClass* );
void AccumSpacetimeCorr (MakeSqtClass*); // __threadsafe__
#endif