-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjob.cpp
More file actions
382 lines (366 loc) · 15.3 KB
/
job.cpp
File metadata and controls
382 lines (366 loc) · 15.3 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
//job.cpp
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <cstdlib>
#include "molecule.h"
#include "transform.h"
#include "electrode.h"
#include "job.h"
void Job::PresentSelection(std::string moleName)
{
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
std::cout << "Molecule: " << moleName << "\n";
for (int j=0; j<moleVec[i].jobMole.GetAtomCount(); j++)
{
std::cout << j << "). " << moleVec[i].jobMole.GetAtomSym(j) << " ";
std::cout << moleVec[i].jobMole.GetAtomCoord(j,'x') << " ";
std::cout << moleVec[i].jobMole.GetAtomCoord(j,'y') << " ";
std::cout << moleVec[i].jobMole.GetAtomCoord(j,'z') << "\n";
}
break;
}
}
return;
}
void Job::INIT(std::string filename, std::string filetype, std::string moleName)
{
moleVec.push_back(Molecules());
moleVec[moleVec.size()-1].name = moleName;
moleVec[moleVec.size()-1].jobMole.Initiate(filename, filetype);
return;
}
void Job::PRINT(std::string filename, std::string filetype, std::string moleName)
{
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
moleVec[i].jobMole.PrintInfo(filename, filetype);
}
}
return;
}
void Job::SORT(std::string moleName, std::string axis)
{
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
char * axischar = new char[1]();
strcpy(axischar,axis.c_str());
moleVec[i].jobMole.SortByCoord(*axischar);
}
}
}
void Job::ALIGN(std::string moleName, std::string STRaxis)
{
char axis = STRaxis.at(0); std::string atom1; std::string atom2;
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
PresentSelection(moleVec[i].name);
std::cout << "\nMoleMod is in the Align phase!\nWhat atoms would you like to select?";
std::cout << "\nAtom 1 (centered): "; std::cin >> atom1;
std::cout << "\nAtom 2 (aligned): "; std::cin >> atom2;
std::cout << "\n\n\n";
int A1 = atoi(atom1.c_str()); int A2 = atoi(atom2.c_str());
TF.AlignAxis(moleVec[i].jobMole,axis,A1,A2);
}
}
return;
}
void Job::DEVICE_SWITCH(std::string moleName, std::string angleDisp, std::string angleInc)
{
char * tokChar; char * charLine;
std::string atom1, atom2, atom3, atom4, atomlist1, atomlist2, filenamechosen;
std::vector<int> atomSelRot, atomSelRec;
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
PresentSelection(moleVec[i].name);
std::cout << "\nMoleMod is in the Device Switch phase!\nLets define rotation 1";
std::cout << "\nAxis 1; Atom 1: "; std::cin >> atom1;
std::cout << "\nAxis 1; Atom 2: "; std::cin >> atom2;
std::cout << "\nAtoms affected? (separate by commas only):"; std::cin >> atomlist1;
std::cout << "\nNow lets define rotation 2";
std::cout << "\nAxis 2; Atom 1: "; std::cin >> atom3;
std::cout << "\nAxis 2; Atom 2: "; std::cin >> atom4;
std::cout << "\nAtoms affected? (separate by commas only):"; std::cin >> atomlist2;
std::cout << "\nWhat will the name of the rotated geometries be:"; std::cin >> filenamechosen;
int axiAtoms[4] = {atoi(atom1.c_str()),atoi(atom2.c_str()),atoi(atom3.c_str()),atoi(atom4.c_str())};
charLine = new char[atomlist1.length()+1]();
strcpy(charLine,atomlist1.c_str());
tokChar = strtok(charLine,",");
while (tokChar != NULL)
{
atomSelRot.push_back(atoi(tokChar));
tokChar = strtok(NULL,",");
}
delete [] charLine;
charLine = new char[atomlist2.length()+2]();
strcpy(charLine,atomlist2.c_str());
tokChar = strtok(charLine,",");
while (tokChar != NULL)
{
atomSelRec.push_back(atoi(tokChar));
tokChar = strtok(NULL,",");
}
TF.DeviceSwitch_ODSP(moleVec[i].jobMole, axiAtoms, atof(angleDisp.c_str()), atof(angleInc.c_str()), atomSelRot, atomSelRec, filenamechosen);
}
}
return;
}
void Job::HYDROREP_ELECTRODE(std::string moleName)
{
std::string junc1, junc2, Hydro1, Hydro2, MType, A_Mbl, M_Mbl,MCountstr;
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
PresentSelection(moleVec[i].name);
std::cout << "\nMoleMod is in the Hydrogen replaced electrode phase!\nLets get the first electrode!";
std::cout << "\nAtom bonded to gold: "; std::cin >> junc1;
std::cout << "\nHydrogen to be replaced: "; std::cin >> Hydro1;
std::cout << "\nNow lets get the second electrode";
std::cout << "\nAtom bonded to gold: "; std::cin >> junc2;
std::cout << "\nHydrogen to be replaced: "; std::cin >> Hydro2;
std::cout << "\nAtomic symbol of the metal: "; std::cin >> MType;
std::cout << "\nAtom-Electrode bond length (S-Au = 2.62): "; std::cin >> A_Mbl;
std::cout << "\nAtom-Electrode bond length (Au-Au = 2.88): "; std::cin >> M_Mbl;
std::cout << "\n# of Electrode atoms on each electrode: "; std::cin >> MCountstr;
int juncAtoms[4] = {atoi(junc1.c_str()),atoi(Hydro1.c_str()),atoi(junc2.c_str()),atoi(Hydro2.c_str())};
double BL1 = atof(A_Mbl.c_str()); double BL2 = atof(M_Mbl.c_str());
int MCount = atoi(MCountstr.c_str());
ELE.HydroRepElectrode(moleVec[i].jobMole, MCount, MType, juncAtoms, BL1,BL2);
}
}
return;
}
void Job::LINEAR_ELECTRODE(std::string moleName)
{
std::string junc1, junc2, Hydro1, Hydro2, MType, A_Mbl, M_Mbl,MCountstr, YesNo;
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
PresentSelection(moleVec[i].name);
std::cout << "\nMoleMod is in the Linear electrode phase!\nLets get the first electrode!";
std::cout << "\nDo you plan on replacing hydrogens with an electrode (Y/N): "; std::cin >> YesNo;
std::cout << "\nAtom bonded to gold: "; std::cin >> junc1;
std::cout << "\nHydrogen to be replaced: "; std::cin >> Hydro1;
std::cout << "\nNow lets get the second electrode";
std::cout << "\nAtom bonded to gold: "; std::cin >> junc2;
std::cout << "\nHydrogen to be replaced: "; std::cin >> Hydro2;
std::cout << "\nAtomic symbol of the metal: "; std::cin >> MType;
std::cout << "\nAtom-Electrode bond length (S-Au = 2.62): "; std::cin >> A_Mbl;
std::cout << "\nAtom-Electrode bond length (Au-Au = 2.88): "; std::cin >> M_Mbl;
std::cout << "\n# of Electrode atoms on each electrode: "; std::cin >> MCountstr;
int juncAtoms[4] = {atoi(junc1.c_str()),atoi(Hydro1.c_str()),atoi(junc2.c_str()),atoi(Hydro2.c_str())};
double BL1 = atof(A_Mbl.c_str()); double BL2 = atof(M_Mbl.c_str());
int MCount = atoi(MCountstr.c_str());
if (YesNo == "Y" || YesNo == "y") { ELE.LinearElectrode(moleVec[i].jobMole, MCount, MType, juncAtoms, BL1, BL2, true);}
else { ELE.LinearElectrode(moleVec[i].jobMole, MCount, MType, juncAtoms, BL1, BL2, false);}
}
}
return;
}
void Job::TIPSQUARE_ELECTRODE(std::string moleName)
{
std::string junc1,junc2,MType,A_Mbl,M_Mbl,Hydro1,Hydro2;
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
PresentSelection(moleVec[i].name);
std::cout << "\nMoleMod is in the Square Tipped electrode phase!\nLets get the first electrode!";
std::cout << "\nAtom bonded to gold: "; std::cin >> junc1;
std::cout << "\nHydrogen to be replaced: "; std::cin >> Hydro1;
std::cout << "\nNow lets get the second electrode";
std::cout << "\nAtom bonded to gold: "; std::cin >> junc2;
std::cout << "\nHydrogen to be replaced: "; std::cin >> Hydro2;
std::cout << "\nAtomic symbol of the metal: "; std::cin >> MType;
std::cout << "\nAtom-Electrode bond length (S-Au = 2.62): "; std::cin >> A_Mbl;
std::cout << "\nAtom-Electrode bond length (Au-Au = 2.88): "; std::cin >> M_Mbl;
int juncAtoms[4] = {atoi(junc1.c_str()),atoi(junc2.c_str()),atoi(Hydro1.c_str()),atoi(Hydro2.c_str())};
double BL1 = atof(A_Mbl.c_str()); double BL2 = atof(M_Mbl.c_str());
ELE.TipSquareElectrode(moleVec[i].jobMole, MType, juncAtoms, BL1,BL2);
}
}
return;
}
void Job::PYRAMID_ELECTRODE(std::string moleName)
{
std::string junc1, junc2, MType, A_Mbl, M_Mbl, layerIter, Hydro1, Hydro2;
for (int i=0; i<moleVec.size(); i++)
{
if (moleName == moleVec[i].name)
{
PresentSelection(moleVec[i].name);
std::cout << "\nMoleMod is in the Pyramid electrode phase!\nLets get the first electrode!";
std::cout << "\nAtom bonded to gold: "; std::cin >> junc1;
std::cout << "\nHydrogen to be replaced: "; std::cin >> Hydro1;
std::cout << "\nNow lets get the second electrode";
std::cout << "\nAtom bonded to gold: "; std::cin >> junc2;
std::cout << "\nHydrogen to be replaced: "; std::cin >> Hydro2;
std::cout << "\nAtomic symbol of the metal: "; std::cin >> MType;
std::cout << "\nHow many layers will the pyramid have: "; std::cin >> layerIter;
std::cout << "\nAtom-Electrode bond length (S-Au = EDIT): "; std::cin >> A_Mbl;
std::cout << "\nAtom-Electrode bond length (Au-Au = EDIT): "; std::cin >> M_Mbl;
int juncAtoms[4] = {atoi(junc1.c_str()),atoi(junc2.c_str()),atoi(Hydro1.c_str()),atoi(Hydro2.c_str())};
int layers = atoi(layerIter.c_str());
double BL1 = atof(A_Mbl.c_str()); double BL2 = atof(M_Mbl.c_str());
ELE.PyramidElectrode(moleVec[i].jobMole, layers, MType, juncAtoms, BL1,BL2);
}
}
return;
}
void Job::CUSTOM_ELECTRODE(std::string juncName, std::string elecName)
{
//Values we want to store
int juncNum, elecNum;
std::string junc1, junc2, ele1, aliJunc1, aliJunc2, aliEle1, aliEle2, BondLength;
for (int i=0; i<moleVec.size(); i++)
{
if (juncName == moleVec[i].name){ juncNum = i; }
if (elecName == moleVec[i].name){ elecNum = i; }
}
PresentSelection(moleVec[elecNum].name);
PresentSelection(moleVec[juncNum].name);
std::cout << "\nMoleMod is in the Custom electrode phase!\nLets start aligning!";
std::cout << "\nOn the junction, which atom would you like centered? "; std::cin >> aliJunc1;
std::cout << "\nOn the junction, which atom would you like aligned? "; std::cin >> aliJunc2;
std::cout << "\nOn the electrode, which atom would you like centered? "; std::cin >> aliEle1;
std::cout << "\nOn the electrode, which atom would you like aligned? "; std::cin >> aliEle2;
std::cout << "\nNow lets begin attaching atoms!";
std::cout << "\nWhich atom would you like connected to the electrode? "; std::cin >> junc1;
std::cout << "\nWhat is the other atom you would like connected to the electrode? "; std::cin >> junc2;
std::cout << "\nWhich atom would you like connected to the junction? "; std::cin >> ele1;
std::cout << "\nJunction to Electrode bond length? "; std::cin >> BondLength;
int juncEle[7] = {atoi(junc1.c_str()),atoi(junc2.c_str()),atoi(ele1.c_str()),atoi(aliJunc1.c_str()),atoi(aliJunc2.c_str()),atoi(aliEle1.c_str()),atoi(aliEle2.c_str())};
double BL = atof(BondLength.c_str());
ELE.CustomElectrode(moleVec[elecNum].jobMole,moleVec[juncNum].jobMole,juncEle,BL);
}
void Job::ADDCUSTOM_ELECTRODE(std::string juncName, std::string elecName, std::string elecName2)
{
//Values we want to store
int juncNum,elecNum,elecNum2;
std::string junc1, junc2, ele1, ele2, aliJunc1, aliJunc2, aliEle1, aliEle2, aliEle3, aliEle4, BondLength;
for (int i=0; i<moleVec.size(); i++)
{
if(juncName == moleVec[i].name){juncNum = i;}
if(elecName == moleVec[i].name){ elecNum = i;}
if(elecName2 == moleVec[i].name){elecNum2 = i;}
}
PresentSelection(moleVec[elecNum].name);
PresentSelection(moleVec[juncNum].name);
PresentSelection(moleVec[elecNum2].name);
std::cout << "\nMoleMod is in the Custom electrodes phase!\nLets start aligning!";
std::cout << "\nOn the junction, which atom would you like centered? "; std::cin >> aliJunc1;
std::cout << "\nOn the junction, which atom would you liked aligned? "; std::cin >> aliJunc2;
std::cout << "\nOn the Left Electrode, which atom would you like centered? "; std::cin >> aliEle1;
std::cout << "\nOn the Left Electrode, which atom would you like aligned? "; std::cin >> aliEle2;
std::cout << "\nTime to attach the left electrode!";
std::cout << "\nWhich atom would you like connected to the Left Electrode?"; std::cin >> junc1;
std::cout << "\nWhich atom would you like connected to the junction? "; std::cin >> ele1;
std::cout << "On the Right Electrode, which atom would you centered? "; std::cin >> aliEle3;
std::cout << "On the Right Electrode, which atom would you like aligned? "; std::cin >> aliEle4;
std::cout << "Time to attach the right electrode!";
std::cout << "Which atom would you like connected to the Right Electrode?"; std::cin >> junc2;
std::cout << "Which atom would you like connected to the junction?"; std::cin >> ele2;
std::cout << "Junction to Electrodes bond length? "; std::cin >> BondLength;
int juncEle[10] = {atoi(junc1.c_str()),atoi(junc2.c_str()),atoi(ele1.c_str()),atoi(ele2.c_str()),atoi(aliJunc1.c_str()),atoi(aliJunc2.c_str()),atoi(aliEle1.c_str()),atoi(aliEle2.c_str()),atoi(aliEle3.c_str()),atoi(aliEle4.c_str())};
double BL = atof(BondLength.c_str());
ELE.AddCustomElectrode(moleVec[elecNum].jobMole,moleVec[juncNum].jobMole,moleVec[elecNum2].jobMole,juncEle,BL);
}
void Job::run(std::string mmFile)
{
std::cout << "Currently working with: " << mmFile << "\n";
std::string strLine;
std::string command; char * tokChar;
char * charLine;
int strlength;
std::ifstream inputFile(mmFile.c_str());
if (!inputFile){std::cout << mmFile << " was not found\n"; return;}
while (getline(inputFile, strLine))
{
strlength = strLine.length();
charLine = new char[strlength+1]();
strcpy(charLine, strLine.c_str());
tokChar = strtok(charLine," "); command = tokChar;
if (command == "INIT")
{
tokChar = strtok(NULL," "); std::string INIT_1 = tokChar;
tokChar = strtok(NULL," "); std::string INIT_2 = tokChar;
tokChar = strtok(NULL," "); std::string INIT_3 = tokChar;
INIT(INIT_1, INIT_2, INIT_3);
}
if (command == "PRINT")
{
tokChar = strtok(NULL," "); std::string PRINT_1 = tokChar;
tokChar = strtok(NULL," "); std::string PRINT_2 = tokChar;
tokChar = strtok(NULL," "); std::string PRINT_3 = tokChar;
PRINT(PRINT_1, PRINT_2, PRINT_3);
}
if (command == "ALIGN")
{
tokChar = strtok(NULL," "); std::string ALIGN_1 = tokChar;
tokChar = strtok(NULL," "); std::string ALIGN_2 = tokChar;
ALIGN(ALIGN_1, ALIGN_2);
}
if (command == "DEVICE_SWITCH")
{
tokChar = strtok(NULL," "); std::string DS_1 = tokChar;
tokChar = strtok(NULL," "); std::string DS_2 = tokChar;
tokChar = strtok(NULL," "); std::string DS_3 = tokChar;
DEVICE_SWITCH(DS_1,DS_2,DS_3);
}
if (command == "HR_ELEC")
{
tokChar = strtok(NULL," "); std::string HRE_1 = tokChar;
HYDROREP_ELECTRODE(HRE_1);
}
if (command == "L_ELEC")
{
tokChar = strtok(NULL," "); std::string LE_1 = tokChar;
LINEAR_ELECTRODE(LE_1);
}
if (command == "SORT")
{
tokChar = strtok(NULL," "); std::string S_1 = tokChar;
tokChar = strtok(NULL," "); std::string S_2 = tokChar;
SORT(S_1,S_2);
}
if (command == "TSQ_ELEC")
{
tokChar = strtok(NULL," "); std::string TSQE_1 = tokChar;
TIPSQUARE_ELECTRODE(TSQE_1);
}
if (command == "PYR_ELEC")
{
tokChar = strtok(NULL," "); std::string PYRE_1 = tokChar;
PYRAMID_ELECTRODE(PYRE_1);
}
if (command == "CUS_ELEC")
{
tokChar = strtok(NULL," "); std::string CUSE_1 = tokChar;
tokChar = strtok(NULL," "); std::string CUSE_2 = tokChar;
CUSTOM_ELECTRODE(CUSE_1,CUSE_2);
}
if (command == "ADDCUS_ELECS")
{
tokChar = strtok(NULL," "); std::string CUSE_1 = tokChar;
tokChar = strtok(NULL," "); std::string CUSE_2 = tokChar;
tokChar = strtok(NULL," "); std::string CUSE_3 = tokChar;
ADDCUSTOM_ELECTRODE(CUSE_1,CUSE_2,CUSE_3);
}
delete charLine;
}
return;
}