Lemina
A molecular dynamics package for network, granular material and point particles with a range of interaction potential.
Loading...
Searching...
No Matches
EvalRdf.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
26
void
EvalRdf
(){
27
real
dr[
NDIM
+1], deltaR, normFac, rr, rrRange;
28
int
j1, j2, n;
29
countRdf
++;
30
if
(
countRdf
== 1){
31
for
(n = 1 ; n <=
sizeHistRdf
; n ++)
32
histRdf
[n] = 0.;
33
}
34
rrRange =
Sqr
(
rangeRdf
);
35
deltaR =
rangeRdf
/
sizeHistRdf
;
36
for
(j1 = 1 ; j1 <=
nAtom
- 1 ; j1 ++){
37
for
(j2 = j1 + 1 ; j2 <=
nAtom
; j2 ++){
38
39
dr[1] =
rx
[j1] -
rx
[j2];
40
if
(fabs(dr[1]) >
regionH
[1])
41
dr[1] -=
SignR
(
region
[1], dr[1]);
42
43
dr[2] =
ry
[j1] -
ry
[j2];
44
if
(fabs(dr[2]) >
regionH
[2])
45
dr[2] -=
SignR
(
region
[2], dr[2]);
46
47
rr =
Sqr
(dr[1]) +
Sqr
(dr[2]);
48
49
if
(rr < rrRange){
50
n = (int)(sqrt(rr)/deltaR) + 1;
51
histRdf
[n] ++;
52
}
53
}
54
}
55
56
if
(
countRdf
==
limitRdf
){
57
normFac =
region
[1]*
region
[2] / (M_PI*
Sqr
(deltaR)*
nAtom
*
nAtom
*
countRdf
);
58
for
(n = 1 ; n <=
sizeHistRdf
; n ++)
59
histRdf
[n] *= normFac/(n-0.5);
60
// PRINT THE RADIAL DISTRIBUTION DATA ON TO DISK FILE
61
real
rBin;
62
fprintf(
fprdf
,
"rdf @ timeNow %lf\n"
,
timeNow
);
63
for
(n = 1 ; n <=
sizeHistRdf
; n ++){
64
rBin = (n - 0.5)*
rangeRdf
/
sizeHistRdf
;
65
fprintf(
fprdf
,
"%lf %lf\n"
, rBin,
histRdf
[n]);
66
}
67
}
68
69
}
70
EvalRdf
void EvalRdf()
Definition
EvalRdf.c:26
global.h
nAtom
int nAtom
Definition
global.h:24
real
double real
Definition
global.h:11
NDIM
#define NDIM
Definition
global.h:13
countRdf
int countRdf
limitRdf
int limitRdf
Definition
global.h:104
region
double region[2+1]
rx
double * rx
Sqr
#define Sqr(x)
Definition
global.h:14
histRdf
double * histRdf
fprdf
FILE * fprdf
timeNow
double timeNow
Definition
global.h:20
sizeHistRdf
int sizeHistRdf
Definition
global.h:104
rangeRdf
double rangeRdf
Definition
global.h:103
regionH
double regionH[2+1]
Definition
global.h:20
SignR
#define SignR(x, y)
Definition
global.h:15
ry
double * ry
Definition
global.h:17
source
EvalRdf.c
Generated by
1.13.2