Lemina
A molecular dynamics package for network, granular material and point particles with a range of interaction potential.
 
Loading...
Searching...
No Matches
ApplyDrivingForce.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"global.h"
24
26 int n;
27 double Vxblock, Vyblock;
28 double Vxsubstrate, Vysubstrate;
29 Vxblock = 0.0; Vyblock = 0.0;
30 Vxsubstrate = 0.0; Vysubstrate = 0.0;
31 double gammav;
32 gammav = 0.0;
33
34 double count_substrate = 0;
35 double count_block = 0;
36
37 for(n = 1 ; n <= nAtom; n ++){
38 if(atomType[n] == 1 || atomType[n] == 2){
39 Vxsubstrate += vx[n]; Vysubstrate += vy[n];
40 count_substrate++;
41 }
42 if(atomType[n] == 3 || atomType[n] == 4){
43 Vxblock += vx[n]; Vyblock += vy[n];
44 count_block++;
45 } }
46
47 if(count_substrate > 0) {
48 Vxsubstrate /= count_substrate;
49 Vysubstrate /= count_substrate;
50 }
51
52 if(count_block > 0) {
53 Vxblock /= count_block;
54 Vyblock /= count_block;
55 }
56
57 for(n = 1 ; n <= nAtom; n ++){
58 if(atomType[n] == 1 || atomType[n] == 2){
59 ax[n] += -gammav * (vx[n] - Vxsubstrate);
60 ay[n] += -gammav * (vy[n] - Vysubstrate);
61 }
62 if(atomType[n] == 3 || atomType[n] == 4){
63 ax[n] += -gammav * (vx[n] - Vxblock);
64 ay[n] += -gammav * (vy[n] - Vyblock);
65 } } }
66
67
void ApplyDrivingForce()
int nAtom
Definition global.h:24
double * ay
Definition global.h:17
double * vx
Definition global.h:17
double * ax
Definition global.h:17
int * atomType
double * vy
Definition global.h:17