Lemina
A molecular dynamics package for network, granular material and point particles with a range of interaction potential.
 
Loading...
Searching...
No Matches
ApplyBoundaryCond.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "global.h"
+ Include dependency graph for ApplyBoundaryCond.c:

Go to the source code of this file.

Functions

void ApplyBoundaryCond ()
 

Function Documentation

◆ ApplyBoundaryCond()

void ApplyBoundaryCond ( )

Definition at line 27 of file ApplyBoundaryCond.c.

27 {
28 int n;
29 for(n = 1 ; n <= nAtom ; n ++){
30 if(strcmp(xBoundary, "p") == 0 && strcmp(yBoundary, "p") == 0){ // P.B.C along x and y axis
31 rx[n] -= region[1]*rint(rx[n]/region[1]);
32 ry[n] -= region[2]*rint(ry[n]/region[2]);
33 } else if (strcmp(xBoundary, "r") == 0 && strcmp(yBoundary, "r") == 0){ //R.B.C. along x and y axis
34 if((rx[n] + atomRadius[n]) >= regionH[1]){
35 rx[n] = 0.999999*regionH[1] - atomRadius[n]; vx[n] = -vx[n] ;
36 }if((rx[n]-atomRadius[n]) < -regionH[1]){
37 rx[n] = -0.999999*regionH[1] + atomRadius[n]; vx[n] = -vx[n] ;
38 }
39 if((ry[n] + atomRadius[n])>= regionH[2]){
40 ry[n] = 0.999999*regionH[2] - atomRadius[n]; vy[n] = -vy[n] ;
41 }if((ry[n]-atomRadius[n]) < -regionH[2]){
42 ry[n] = -0.999999*regionH[2] + atomRadius[n]; vy[n] = -vy[n] ;
43 }}
44 else if (strcmp(xBoundary, "p") == 0 && strcmp(yBoundary, "r") == 0){ //P.B.C. along x and R.B.C along y axis
45 rx[n] -= region[1]*rint(rx[n]/region[1]);
46 if((ry[n] + atomRadius[n]) >= regionH[2]){
47 ry[n] = 0.999999*regionH[2] - atomRadius[n]; vy[n] = -vy[n] ;
48 }if((ry[n] - atomRadius[n]) < -regionH[2]){
49 ry[n] = -0.999999*regionH[2] + atomRadius[n]; vy[n] = -vy[n] ;
50 }}
51 else if(strcmp(xBoundary, "r") == 0 && strcmp(yBoundary, "p") == 0){ //R.B.C. along x and P.B.C along y axis
52 if((rx[n] + atomRadius[n]) >= regionH[1]){
53 rx[n] = 0.999999*regionH[1] - atomRadius[n]; vx[n] = -vx[n] ;
54 }if((rx[n] - atomRadius[n]) < -regionH[1]){
55 rx[n] = -0.999999*regionH[1] + atomRadius[n]; vx[n] = -vx[n] ;
56 }
57 ry[n] -= region[2]*rint(ry[n]/region[2]);
58 } else {
59 // Print error message and exit the program
60 fprintf(fpresult, "Error: Invalid boundary configuration: '%s %s'\n", xBoundary, yBoundary);
61 exit(EXIT_FAILURE); // Exit with failure status
62 }
63 }
64}
int nAtom
Definition global.h:24
double region[2+1]
char yBoundary[10]
Definition global.h:68
double * vx
Definition global.h:17
FILE * fpresult
double * rx
double * atomRadius
char xBoundary[10]
double * vy
Definition global.h:17
double regionH[2+1]
Definition global.h:20
double * ry
Definition global.h:17

References atomRadius, fpresult, nAtom, region, regionH, rx, ry, vx, vy, xBoundary, and yBoundary.

Referenced by main().

+ Here is the caller graph for this function: