Lemina
A molecular dynamics package for network, granular material and point particles with a range of interaction potential.
 
Loading...
Searching...
No Matches
VelocityVerletStep.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
26void VelocityVerletStep(int icode){
27int n;
28double atomMassi;
29
30 if(icode == 1){
31 for (n= 1; n <= nAtom; n++) {
32 if(atomType[n] != freezeAtomType){
33 atomMassi = 1./atomMass[n];
34 ax[n] = fx[n] * atomMassi; ay[n] = fy[n] * atomMassi;
35 vx[n] += ax[n] * 0.5 * deltaT;
36 vy[n] += ay[n] * 0.5 * deltaT;
37 rx[n] += vx[n] * deltaT;
38 ry[n] += vy[n] * deltaT;
39 }
40 //Calculating the image flags here
41 if (rx[n] >= regionH[1]) {
42 rx[n] -= region[1];
43 ImageX[n]++;
44 } else if (rx[n] < -regionH[1]) {
45 rx[n] += region[1];
46 ImageX[n]--;
47 }
48 if (ry[n] >= regionH[2]) {
49 ry[n] -= region[2];
50 ImageY[n]++;
51 } else if (ry[n] < -regionH[2]) {
52 ry[n] += region[2];
53 ImageY[n]--;
54 } } }
55 else if(icode == 2){
56 for(n = 1; n <= nAtom; n++) {
57 if(atomType[n] != freezeAtomType){
58 atomMassi = 1./atomMass[n];
59 ax[n] = fx[n] * atomMassi; ay[n] = fy[n] * atomMassi;
60 vx[n] += ax[n] * 0.5 * deltaT;
61 vy[n] += ay[n] * 0.5 * deltaT;
62} } } }
63
void VelocityVerletStep(int icode)
int nAtom
Definition global.h:24
double * atomMass
double region[2+1]
double * ay
Definition global.h:17
double * vx
Definition global.h:17
int * ImageX
int * ImageY
Definition global.h:50
int freezeAtomType
double deltaT
Definition global.h:20
double * rx
double * ax
Definition global.h:17
double * fy
Definition global.h:17
int * atomType
double * vy
Definition global.h:17
double regionH[2+1]
Definition global.h:20
double * fx
Definition global.h:17
double * ry
Definition global.h:17