Lemina
A molecular dynamics package for network, granular material and point particles with a range of interaction potential.
Loading...
Searching...
No Matches
BrownianStep.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
#include<stdio.h>
22
#include<stdlib.h>
23
#include<math.h>
24
#include"
global.h
"
25
26
void
BrownianStep
(){
27
if
(
stepCount
<=
stepEquil
){
28
double
A, S1, S2, T;
29
int
n;
30
S1 = 0.; S2 = 0;
31
double
halfdt = 0.5*
deltaT
;
32
for
(n = 1; n <=
nAtom
; n++){
33
T =
vx
[n] + halfdt *
ax
[n];
34
S1 += T *
ax
[n];
35
S2 +=
Sqr
(T);
36
37
T =
vy
[n] + halfdt *
ay
[n];
38
S1 += T *
ay
[n];
39
S2 +=
Sqr
(T);
40
}
41
A = -S1 / S2;
42
double
C = 1 + A*
deltaT
;
43
double
D =
deltaT
* (1 + 0.5 * A *
deltaT
);
44
for
(n = 1; n <=
nAtom
; n++){
45
vx
[n] = C *
vx
[n] + D *
ax
[n];
46
rx
[n] +=
deltaT
*
vx
[n];
47
vy
[n] = C *
vy
[n] + D *
ay
[n];
48
ry
[n] +=
deltaT
*
vy
[n];
49
}
50
}
else
{
51
int
n;
52
//SETTING TEMP = 0.0
53
if
(
stepCount
==
stepEquil
+1){
54
for
(n = 1 ; n <=
nAtom
; n ++){
55
vx
[n] = 0.0;
56
vy
[n] = 0.0;
57
}}
58
double
zeta = 1.0;
59
double
dx, dy;
60
for
(n = 1 ; n <=
nAtom
; n ++){
61
dx =
rx
[n];
62
rx
[n] += zeta *
ax
[n] *
deltaT
;
63
dx =
rx
[n] - dx;
64
vx
[n] = dx/
deltaT
;
65
dy =
ry
[n];
66
ry
[n] += zeta *
ay
[n] *
deltaT
;
67
dy =
ry
[n] - dy;
68
vy
[n] = dy/
deltaT
;
69
}
70
}
71
}
72
BrownianStep
void BrownianStep()
Definition
BrownianStep.c:26
global.h
nAtom
int nAtom
Definition
global.h:24
ay
double * ay
Definition
global.h:17
vx
double * vx
Definition
global.h:17
deltaT
double deltaT
Definition
global.h:20
rx
double * rx
ax
double * ax
Definition
global.h:17
Sqr
#define Sqr(x)
Definition
global.h:14
stepEquil
int stepEquil
Definition
global.h:24
stepCount
int stepCount
Definition
global.h:24
vy
double * vy
Definition
global.h:17
ry
double * ry
Definition
global.h:17
source
BrownianStep.c
Generated by
1.13.2