Lemina
A molecular dynamics package for network, granular material and point particles with a range of interaction potential.
 
Loading...
Searching...
No Matches
EvalProps.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 <string.h>
24#include "global.h"
25
26void EvalProps() {
27 double v;
28 int n;
29 double atomMassn;
30 double KineEnrXSum, KineEnrYSum;
31 virSum = 0.0;
32 vSumX = 0.0; vSumY = 0.0; vSum = 0.0; vvSum = 0.0;
33 KineEnrXSum = 0.0; KineEnrYSum = 0.0;
34
35 for (n = 1; n <= nAtom; n++) {
36 // Initialize v with a default value to avoid "uninitialized" warning.
37 v = 0.0;
38 atomMassn = atomMass[n];
39 // X direction velocity
40 if (strcmp(solver, "Verlet") == 0) {
41 v = vx[n];
42 } else if (strcmp(solver, "LeapFrog") == 0) {
43 v = vx[n] - 0.5 * deltaT * ax[n];
44 }
45 vSum += v;
46 vvSum += Sqr(v);
47 KineEnrXSum += 0.5 * atomMassn * Sqr(v);
48 vSumX += v;
49 // Y direction velocity
50 if (strcmp(solver, "Verlet") == 0) {
51 v = vy[n];
52 } else if (strcmp(solver, "LeapFrog") == 0) {
53 v = vy[n] - 0.5 * deltaT * ay[n];
54 }
55 vSum += v;
56 vSumY += v;
57 vvSum += Sqr(v);
58 KineEnrYSum += 0.5 * atomMassn * Sqr(v);
59 }
60
61 kinEnergy = (KineEnrXSum + KineEnrYSum) / nAtom ;
63 BondEnergyPerAtom = TotalBondEnergy / (0.5*nAtom); //Factor of 0.5 since each atom has one half the bond energy
70 pressure = density * (vvSum + virSum) / (nAtom * NDIM);
71
72}
73
void EvalProps()
Definition EvalProps.c:26
double totEnergy
Definition global.h:20
double virSumBond
int nAtom
Definition global.h:24
double * atomMass
double virSumPairyy
Definition global.h:88
double virSumyy
Definition global.h:90
double virSumPair
Definition global.h:88
#define NDIM
Definition global.h:13
double uSumPairPerAtom
Definition global.h:88
double kinEnergy
Definition global.h:20
double virSumxy
Definition global.h:90
double virSumPairxx
Definition global.h:88
double vvSum
Definition global.h:21
double virSumBondxy
Definition global.h:89
double vSum
Definition global.h:21
double * ay
Definition global.h:17
double * vx
Definition global.h:17
double density
Definition global.h:20
double vSumY
Definition global.h:21
double deltaT
Definition global.h:20
double * ax
Definition global.h:17
#define Sqr(x)
Definition global.h:14
double uSumPair
double BondEnergyPerAtom
Definition global.h:40
double virSumBondxx
Definition global.h:89
char solver[128]
double potEnergy
Definition global.h:20
double virSum
Definition global.h:21
double TotalBondEnergy
double virSumxx
double * vy
Definition global.h:17
double vSumX
Definition global.h:21
double pressure
Definition global.h:21
double virSumBondyy
Definition global.h:89
double virSumPairxy
Definition global.h:88