Lemina
A molecular dynamics package for network, granular material and point particles with a range of interaction potential.
 
Loading...
Searching...
No Matches
PrintForceSum.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
23#include<stdio.h>
24#include<stdlib.h>
25#include<math.h>
26#include"global.h"
27
29 int n;
30 double forceSumxAtomType1, forceSumxAtomType2, forceSumxAtomType3, forceSumxAtomType4, forceSumxAtomType5;
31 double forceSumyAtomType1, forceSumyAtomType2, forceSumyAtomType3, forceSumyAtomType4, forceSumyAtomType5;
32
33 forceSumxAtomType1 = 0.0; forceSumyAtomType1 = 0.0;
34 forceSumxAtomType2 = 0.0; forceSumyAtomType2 = 0.0;
35 forceSumxAtomType3 = 0.0; forceSumyAtomType3 = 0.0;
36 forceSumxAtomType4 = 0.0; forceSumyAtomType4 = 0.0;
37 forceSumxAtomType5 = 0.0; forceSumyAtomType5 = 0.0;
38
39
40 for(n = 1; n <= nAtom; n++){
41 if(atomType[n] == 1){
42 forceSumxAtomType1 += fx[n];
43 forceSumyAtomType1 += fy[n];
44 } else if(atomType[n] == 2){
45 forceSumxAtomType2 += fx[n];
46 forceSumyAtomType2 += fy[n];
47 } else if(atomType[n] == 3){
48 forceSumxAtomType3 += fx[n];
49 forceSumyAtomType3 += fy[n];
50 } else if(atomType[n] == 4){
51 forceSumxAtomType4 += fx[n];
52 forceSumyAtomType4 += fy[n];
53 } else if(atomType[n] == 5){
54 forceSumxAtomType5 += fx[n];
55 forceSumyAtomType5 += fy[n];
56 }
57 }
58
59 fprintf(fpforce, "%0.4lf\t%0.16lf\t%0.16lf\t%0.16lf\t%0.16lf\t%0.16f\t%0.16lf\t%0.16lf\t%0.16lf\t%0.16lf\t%0.16lf\t%0.16f\t%0.16f\n", timeNow,
60 forceSumxAtomType1, forceSumyAtomType1,
61 forceSumxAtomType2, forceSumyAtomType2,
62 forceSumxAtomType3, forceSumyAtomType3,
63 forceSumxAtomType4, forceSumyAtomType4,
64 forceSumxAtomType5, forceSumyAtomType5,
66 fflush(fpforce);
67 }
68
69
70
void PrintForceSum()
int nAtom
Definition global.h:24
FILE * fpforce
double * fy
Definition global.h:17
double timeNow
Definition global.h:20
double forceSumyExtern
Definition global.h:53
int * atomType
double forceSumxExtern
Definition global.h:53
double * fx
Definition global.h:17