-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
166 lines (144 loc) · 6.84 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/** *************************************************************** **/
/** regidx C++ code - 2016 **/
/** **/
/** ** Registry Index for Bilayer Carbon Based Systems ** **/
/** **/
/** Written by Pedro Brandimarte ([email protected]) **/
/** **/
/** Copyright (c), All Rights Reserved **/
/** **/
/** This program is free software. You can redistribute it and/or **/
/** modify it under the terms of the GNU General Public License **/
/** (version 3 or later) as published by the Free Software **/
/** Foundation <http://fsf.org/>. **/
/** **/
/** This program is distributed in the hope that it will be useful, **/
/** but WITHOUT ANY WARRANTY, without even the implied warranty of **/
/** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **/
/** GNU General Public License for more details (file 'LICENSE_GPL' **/
/** distributed along with this program or at **/
/** <http://www.gnu.org/licenses/gpl.html>). **/
/** *************************************************************** **/
/** File: main.c **/
/** **/
/** Description: This is a (client) program that receives 2 'xyz' **/
/** files, containing the x, y and z coordinates from the carbon **/
/** atoms from the bottom and top structures, and compute the **/
/** registry index defined as: **/
/** **/
/** RI = (S_{cc} - S^{AB}_{cc}) / (S^{AA}_{cc} - S^{AB}_{cc}), **/
/** **/
/** where 'S_{cc}' is the projected overlap between circles **/
/** assigned to each carbon atomic center from different layers. **/
/** The RI is normalized considering the case with biggest **/
/** interlayer overlapping (worst case) which happens to be the AA **/
/** stacking, and the case with lowest overlapping (optimal case) **/
/** which happens to be the AB stacking. **/
/** **/
/** Usage: ./regidx bottom.xyz top.xyz **/
/** **/
/** Written by Pedro Brandimarte, Feb 2016. **/
/** Centro de Fisica de Materiales - CFM **/
/** Donostia - San Sebastian, Spain **/
/** e-mail: [email protected] **/
/** ***************************** HISTORY ************************* **/
/** Original version: February 2016 **/
/** *************************************************************** **/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <ctime>
#include "RI.hpp"
using namespace std;
/* Prints the header on the screen. */
static void header ();
/* Prints the "how to run" on the screen. */
static void howto ();
int main (int nargs, char *arg[])
{
int nAA, nAB;
double time;
clock_t inicial, final;
/* Writes the header on the screen. */
header ();
/* Checks if the input were typed correctly. */
if (nargs != 4 && nargs != 6) {
cerr << "\n Wrong number of arguments!\n";
howto ();
exit (EXIT_FAILURE);
}
/* Time is running. */
inicial = clock();
/* Read coordinate input files. */
RIinit (arg[0], arg[1], arg[2]);
/* Compute total overlap. */
RIoverlap (arg[3]);
/* Compute the registry index. */
if (nargs == 4)
RI ();
else {
nAA = atoi(arg[4]);
nAB = atoi(arg[5]);
RI (nAA, nAB);
}
/* Free memory. */
RIfree ();
/* Calculates the execution time. */
final = clock();
time = (double)(final - inicial) / CLOCKS_PER_SEC;
cout << "\n This calculation took " << setiosflags(ios::fixed)
<< setprecision(2) << time << " seconds.\n\n";
return 0;
} /* main */
/* ******************************************************************* */
/* Prints the header on 'stdout'. */
static void header ()
{
cout << "\n";
cout << "** *******************************************************"
"****** **\n";
cout << "** ** WELCOME TO REGIDX C++ CODE v2016.01 ** "
" **\n";
cout << "** "
" **\n";
cout << "** * Registry Index for Bilayer Carbon Based Systems "
"* **\n";
cout << "** "
" **\n";
cout << "** Written by Pedro Brandimarte ([email protected]) "
" **\n";
cout << "** "
" **\n";
cout << "** Copyright (c), All Rights Reserved "
" **\n";
cout << "** "
" **\n";
cout << "** This program is free software. You can redistribute it "
"and/or **\n";
cout << "** modify it under the terms of the GNU General Public "
"License **\n";
cout << "** (version 3 or later) as published by the Free Software "
" **\n";
cout << "** Foundation <http://fsf.org/>. See the GNU General "
"Public **\n";
cout << "** License for more details. "
" **\n";
cout << "** *******************************************************"
"****** **\n\n";
setvbuf (stdout, NULL, _IONBF, 0); /* print now! */
} /* header */
/* ******************************************************************* */
/* Prints the "how to run" on 'stdout'. */
static void howto ()
{
cerr << "\n Usage:\n";
cerr << " $ regidx"; // arg[0]
cerr << " [bottom xyz coordinate file]"; // arg[1]
cerr << " [top xyz coordinate file] \\\n"; // arg[2]
cerr << " > [circle radius (angstrom)]"; // arg[3]
cerr << " [(optional) # of atoms in AA] \\\n"; // arg[4]
cerr << " > [(optional) # of atoms in AB]\n\n"; // arg[5]
cerr << " Examples: \n";
cerr << " $ regidx bottom.xyz top.xyz 0.71\n";
cerr << " $ regidx bottom.xyz top.xyz 0.71 131 65\n\n";
} /* howto */