-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestSystem.cpp
633 lines (587 loc) · 20.3 KB
/
TestSystem.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
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
/*
* ClassicalSys.cpp
*
* Created on: May 7, 2012
* Author: dstuck
*/
#include "TestSystem.h"
TestSystem::TestSystem(int pSlice, double beta, CoordUtil* coords, PhysicsUtil * phys) : System(), physics(phys) {
// DES Temp:
tempNum = 0;
string tempstr = "potential.txt";
if(phys->isDeltaAI()) {
vFile.open(tempstr.c_str());
}
N = coords->numModes;
P = pSlice;
eps = beta/((double)P);
coorDim = 1;
vector< vector<Particle> > part_init(P,vector<Particle>(N));
part = part_init;
oldPart = part_init;
upToDate.resize(P, true);
sliceCheck.resize(P, 0.0);
oldSliceCheck.resize(P, 0.0);
sliceAnharmonicV.resize(P, 0.0);
oldSliceAnharmonicV.resize(P, 0.0);
avgV = 0.0;
numSteps = 0;
// for(int i=0; i<(int)w.size(); i++) {
// coords.omega[i] = w[i];
// }
// V = new V_UCHO(w);
// vector<double> lambda;
// for(int j=0; j<N; j++){
// lambda.push_back(5);
// }
// V = new V_AQO(w,lambda);
// V = new V_Morse(12.5,2,N);
// V = new V_Morse(0.033,2.0,N); //Corresponds to reasonable molecular values (actually too stiff a spring!)
// V = new V_Morse(0.00298,2.0,N); //Corresponds to reasonable molecular values
// V = new V_Morse(0.176, 1.02, N); //Corresponds to H2 morse potential from http://www1.uprh.edu/rbaretti/MorsePotential15mar2011.htm but 'a' corresponds to 3000 cm-1
// V = new V_Morse(0.176, 1.4886, N); //Corresponds to H2 with omega 4522.42
// V = new V_TinkerExecutable(coords);
// rho = new Rho_Free();
// rho = new Rho_HO(w);
// rho = new Rho_TruncHO(w);
CoordUtil * qchemCoords;
if(phys->isDeltaAI()) {
// We clone coords here since unless readOmega and readGeom are set, they will be overwritten by V_Tinker constructor
qchemCoords = coords->Clone();
}
if(!physics->vType.compare("V_TinkerExecutable")) {
V = new V_TinkerExecutable(coords);
}
else if(!physics->vType.compare("V_Tinker")) {
V = new V_Tinker(coords, eps, beta);
}
else if(!physics->vType.compare("V_Potlib")) {
V = new V_Potlib(coords, eps, beta);
}
else if(!physics->vType.compare("V_Morse")) {
if(physics->morseAlpha != 0.0 && physics->morseDE != 0.0) {
if(physics->morseMass != 0.0) {
V = new V_Morse(coords, physics->morseDE, physics->morseAlpha, physics->morseMass, N);
}
else {
cout << "Warning: morseMass not set. Using default" << endl;
V = new V_Morse(coords, physics->morseDE, physics->morseAlpha, 1837.107017, N);
}
}
else {
cout << "Warning: morseMass not set. Using default" << endl;
V = new V_Morse(coords, 0.176, 1.4886, 1837.107017, N); //H2
}
}
else if(!physics->vType.compare("V_UCHO")) {
V = new V_UCHO(coords->omega);
}
else {
cout << "Error in selecing V" << endl;
exit(-1);
}
harmonicE = 0.0;
for(int i=0; i<N; i++) {
harmonicE += coords->omega[i]/2.0;
}
// cout << "Harmonic Energy is: " << harmonicE << endl;
coords->initInternals();
if(phys->isDeltaAI()) {
V2 = new V_QChem(qchemCoords,coords,eps,beta,physics->charge,physics->multiplicity);
qchemCoords->initInternals();
if(coords->scaleGeom) {
qchemCoords->MakeScalingVec(coords);
}
}
if(!physics->rhoType.compare("Rho_HO")) {
rho = new Rho_HO(coords->omega,physics->lowFrozModes,physics->highFrozModes);
}
else if(!physics->rhoType.compare("Rho_Mixed")) {
rho = new Rho_Mixed(coords->omega,physics->freqCutoff,physics->lowFrozModes,physics->highFrozModes);
}
else if(!physics->rhoType.compare("Rho_Free")) {
rho = new Rho_Free();
}
else if(!physics->rhoType.compare("Rho_TruncHO")) {
rho = new Rho_TruncHO(coords->omega);
}
else {
cout << "Invalid rhoType:\t" << physics->rhoType << endl;
LINE
exit(-1);
}
for(int i=0; i<P; i++){
for(int j=0; j<N; j++){
part[i][j].mass = coords->reducedMass[j];
oldPart[i][j].mass = coords->reducedMass[j];
}
}
vector< vector<double> > cart0;
cart0 = V->GetCoordUtil()->initCart;
for(int i=0; i<P; i++) {
oldCarts.push_back(cart0);
//newCarts.push_back(cart0);
}
newCarts = oldCarts;
// Initialize bead polymers with random walks
Reset();
// for(int i=0; i<(int)coords->omega.size(); i++) {
// cout << i << "\t" << coords->omega[i]/0.00000455633 << endl;
// }
}
TestSystem::~TestSystem() {
// DES Temp:
if(physics->isDeltaAI()) {
vFile.close();
}
delete V;
delete rho;
delete physics;
}
void TestSystem::Reset() {
//*******************************************************
//* Initialize Bead Polymer Positions with Random Walks *
//*******************************************************
// Initialize all beads to center
for(int j=0; j<N; j++) {
for(int i=0; i<P; i++) {
part[i][j].pos.clear();
oldPart[i][j].pos.clear();
for(int k=0; k<coorDim; k++) {
part[i][j].pos.push_back(0.0);
oldPart[i][j].pos.push_back(0.0);
}
}
}
for(int i=0; i<P; i++) {
oldCarts[i] = V->GetCoordUtil()->initCart;
newCarts[i] = oldCarts[i];
}
//// DES Test( PES Scan
// //double scanBegin = -0.2;
// //double scanEnd = 0.2;
// double scanBegin = -0.2; //Bohr, so twice that in Angrstrom
// double scanEnd = 0.2;
// int scanSteps = 10;
// double curX = 0.0;
// int pickedMode = 0;
// //int pickedMode2 = 3;
//// Print out frequencies
// cout << " \tw_Tinker\t\tw_QChem" << endl;
// for(int i=0;i<N; i++) {
// //cout << i << "\t" << V->GetCoordUtil()->omega[i] << "\t" << V2->GetCoordUtil()->omega[i] << endl;
// cout << i << "\t" << V->GetCoordUtil()->omega[i] << endl;
// }
//// Print out masses
// cout << " \tm_Tinker\tm_QChem" << endl;
// for(int i=0;i<N; i++) {
// cout << i << "\t" << V->GetCoordUtil()->reducedMass[i] << endl;
// //cout << i << "\t" << V->GetCoordUtil()->reducedMass[i] << "\t" << V2->GetCoordUtil()->reducedMass[i] << endl;
// }
// //V2->GetCoordUtil()->MakeScalingVec(V->GetCoordUtil());
//
// cout << "x\tV_full\tV_HO" << endl;
/////*
// for(int n=0; n<scanSteps; n++) {
// curX = scanBegin + (scanEnd-scanBegin)/(double)(scanSteps-1)*(double)(n);
// part[0][pickedMode].pos[0]=curX;
//// part[0][pickedMode2].pos[0]=curX/2;
// cout << curX << "\t" << V->GetV(part[0]) << "\t" << -rho->ModifyPotential(part[0]) << endl;
// //V2->GetV(part[0]);
// }
////*/
// exit(-1);
//// DES)
// DES ( independent mode deltaAI
if(physics->isDeltaAI()) {
vector<double> scanEnd;
for(int i=0; i<N; i++) {
double minW = min(V->GetCoordUtil()->omega[i],V2->GetCoordUtil()->omega[i]);
// Set xMax to the classical turning point for n=5 or ~3.5 times the groundstate turning point
// scanEnd.push_back(sqrt(2.0/minW/V->GetCoordUtil()->reducedMass[i]*(5.0+0.5)));
// Nope! Should set it to be at turning point of ~5 kT
scanEnd.push_back(sqrt(10.0/V->GetCoordUtil()->reducedMass[i]/(eps*double(P)))/minW);
//Bohr, so twice that in Angrstrom
}
int scanSteps = 20;
double curX = 0.0;
string filepref = V->GetCoordUtil()->outFileName;
ofstream theFile;
ofstream theFile2;
ofstream theFile3;
theFile.open((filepref+".nGrid").c_str());
theFile << "400" << endl;
theFile.close();
theFile.open((filepref+".omegaMM").c_str());
theFile2.open((filepref+".omegaQM").c_str());
theFile3.open((filepref+".xMax").c_str());
for(int i=0; i<N; i++) {
theFile << V->GetCoordUtil()->omega[i] << "\t";
theFile2 << V2->GetCoordUtil()->omega[i] << "\t";
theFile3 << scanEnd[i] << "\t";
}
theFile << endl;
theFile2 << endl;
theFile3 << endl;
theFile.close();
theFile2.close();
theFile3.close();
theFile.open((filepref+".massMM").c_str());
theFile2.open((filepref+".massQM").c_str());
for(int i=0; i<N; i++) {
theFile << V->GetCoordUtil()->reducedMass[i] << "\t";
theFile2<< V2->GetCoordUtil()->reducedMass[i] << "\t";
}
theFile << endl;
theFile2 << endl;
theFile.close();
theFile2.close();
theFile.open((filepref+".beta").c_str());
theFile << eps*double(P) << endl;
theFile.close();
theFile.open((filepref+".fullMM").c_str());
theFile2.open((filepref+".hoMM").c_str());
theFile3.open((filepref+".hoQM").c_str());
V2->GetV(part[0]);
if(rename("0_pimc.in","equib.in") != 0) {
cout << "Error writing qchem file in TestSystem!" << endl;
}
for(int n=0; n<scanSteps; n++) {
for(int i=0; i<N; i++) {
curX = -scanEnd[i] + (2*scanEnd[i])/(double)(scanSteps-1)*(double)(n);
part[0][i].pos[0]=curX;
theFile << V->GetV(part[0]) << "\t";
theFile2 << -rho->ModifyPotential(part[0]) << "\t";
theFile3 << static_cast<V_QChem*>(V2)->GetVHO(part[0]) << "\t";
V2->GetV(part[0]);
//cout << "mv: " +toString(n)+"_pimc.in" << endl;
//cout << "to: "+ toString(n)+"_"+toString(i)+"_"+filepref+".in" << endl;
if(rename((toString(i+n*N+1)+"_pimc.in").c_str(),(toString(n)+"_"+toString(i)+"_"+filepref+".in").c_str()) != 0) {
cout << "Error writing qchem file in TestSystem!" << endl;
}
part[0][i].pos[0]=0.0;
}
theFile << endl;
theFile2 << endl;
theFile3 << endl;
}
theFile.close();
theFile2.close();
theFile3.close();
exit(-1);
}
// DES)
static int initRanSeed = -time(0);
int bead, beadm1;
vector <double> levyMean;
double levySigma;
int levyInit = physics->numInit;
int snipBegin;
int snipEnd;
// for (int j=0; j<N; j++) {}
for (int j=physics->lowFrozModes; j<N-physics->highFrozModes; j++) {
for(int round=0; round<P/(levyInit+1); round++) {
snipBegin = round*(levyInit+1);
// cout << "snipBegin = " << snipBegin << endl;
snipEnd = (snipBegin+levyInit+1)%P;
// cout << "snipEnd = " << snipEnd << endl;
// cout << "round = " << round << "\t j = " << j << endl;
for (int s=0; s<levyInit; s++) {
bead = (snipBegin+s+1)%P;
beadm1 = (snipBegin+s)%P;
levyMean = rho->GetLevyMean(part[beadm1][j], part[snipEnd][j], (double)(levyInit-s), eps, j);
levySigma = rho->GetLevySigma((double)(levyInit-s), eps, j) / sqrt(part[0][j].mass);
for(int k=0; k<coorDim; k++){
part[bead][j].pos[k] = RandomNum::rangau(levyMean[k], levySigma, &initRanSeed);
}
upToDate[bead] = false;
}
}
int levyLength = P%(levyInit+1) - 2;
snipBegin = P-P%(levyInit+1);
snipEnd = (snipBegin+levyLength+1);
for (int s=0; s<levyLength; s++) {
bead = (snipBegin+s+1)%P;
beadm1 = (snipBegin+s)%P;
levyMean = rho->GetLevyMean(part[beadm1][j], part[snipEnd][j], (double)(levyLength-s), eps, j);
levySigma = rho->GetLevySigma((double)(levyLength-s), eps, j) / sqrt(part[0][j].mass);
for(int k=0; k<coorDim; k++){
part[bead][j].pos[k] = RandomNum::rangau(levyMean[k], levySigma, &initRanSeed);
}
upToDate[bead] = false;
}
}
oldEnergy = 1000000; // TODO: clean this up
oldCheckVal = 100000;
ECheckFlag = false;
}
double TestSystem::GetWeight() {
if(ECheckFlag) {
cout << "I shouldn't be here! Non-Levy flights have been deprecated" << endl;
exit(-1);
CalcEnergy();
return energy;
}
else {
CalcPotential();
// return checkVal*physics->lambdaTI;
return checkVal;
}
}
double TestSystem::GetOldWeight() {
// TODO: Fix this so it doesn't break if using different ECheckFlag on different steps
if(ECheckFlag) {
cout << "DES: I shouldn't be here!" << endl;
return oldEnergy;
}
else {
// return oldCheckVal*physics->lambdaTI;
return oldCheckVal;
}
}
double TestSystem::EstimatorAnharmonicV() { // Anharmonic delta V
if(!physics->isDeltaAI()) {
CalcPotential();
//return checkVal/((double)P);
return anharmonicV/((double)P);
}
else {
//DES: This is no longer used!!!
cout << "DES: I shouldn't be here!" << endl;
// DES: running ab initio thermodynamic integration correction to molecular mechanics
static int seed = -time(0);
int pickedSlice = P*(RandomNum::rand3(&seed));
double pickedV = V->GetV(part[pickedSlice],rho);
double harmV = -rho->ModifyPotential(part[pickedSlice]);
V2->GetV(part[pickedSlice]);
//DES TODO: Make this work for numTI > 1
vFile << tempNum << "\t" << harmV << "\t" << pickedV << endl;
// DES Temp!!!!
//vFile << tempNum << "\t" << part[pickedSlice][0].pos[0] << "\t" << harmV << "\t" << pickedV << "\t" << endl;
tempNum++;
return pickedV;
}
// return exp(double(-eps)*(checkVal));
}
double TestSystem::EstimatorE() {
// avgV = (avgV*double(numSteps) + checkVal)/double(numSteps+1);
// numSteps++;
double est=0;
for(int i=0; i<P; i++) {
est += rho->Estimate(part[i], part[(i+1)%P], eps, P);
}
est += (checkVal)/(double)P;
return est;
}
vector < vector<Particle> > TestSystem::GetParticle() {
return part;
}
void TestSystem::CalcEnergy(){
cout << "I shouldn't be here!" << endl;
energy = 0;
for(int i=0; i<P; i++){
if(!upToDate[i]) {
sliceAnharmonicV[i] = V->GetV(part[i], rho);
}
upToDate[i] = true;
energy += sliceAnharmonicV[i];
}
checkVal = energy;
for(int i=0; i<P; i++){
energy += rho->GetRho(part[i], part[(i+1)%P], eps);
}
// cout << "Energy = " << energy << endl;
}
void TestSystem::CalcPotential(){
checkVal = 0.0;
anharmonicV = 0.0;
for(int i=0; i<P; i++){
if(!upToDate[i]) {
//DES: Set guessCarts and guessModes
//V->GetCoordUtil()->guessCarts = oldCarts[i];
//V->GetCoordUtil()->guessPart = oldPart[i];
// sliceAnharmonicV[i] = V->GetV(part[i], rho);
sliceAnharmonicV[i] = V->GetV(part[i]); // Full V
sliceCheck[i] = sliceAnharmonicV[i] + rho->ModifyPotential(part[i]); //v - v_0
if(physics->lambdaTI != 1.0) {
//cout << "lambdaTI = " << physics->lambdaTI << endl;
sliceAnharmonicV[i] -= V->GetCoordUtil()->GetHarmV(part[i]); //v - vho
sliceCheck[i] -= sliceAnharmonicV[i] * (1.0-physics->lambdaTI); //TODO: Test this
}
//DES Temp:
// sliceCheck[i] = V->GetV(part[i], rho);
// if(sliceCheck[i] != V->GetV(part[i], rho)*physics->lambdaTI) {
// cout << "DES Temp: "<<sliceCheck[i]<<"!="<<V->GetV(part[i], rho)*physics->lambdaTI << endl;
// }
////V->GetCoordUtil()->useGuess = true;
//V->GetCoordUtil()->useGuess = false;
//DES: Read out new carts from guessCarts
//newCarts[i] = V->GetCoordUtil()->guessCarts;
upToDate[i] = true;
}
checkVal += sliceCheck[i];
anharmonicV += sliceAnharmonicV[i];
}
}
void TestSystem::Move(vector<double> prob, double epsMove, int levyNum, int levyModes){
// cout << "Take a step" << endl;
/*
// Random Walks
ECheckFlag = true;
double stepSize = 1.0;
int iPart = static_cast<int>(N*P*prob[1]);
int iCoor = static_cast<int>(coorDim*prob[2]);
part[(iPart-iPart%N)/N][(iPart%N)].pos[iCoor] += (stepSize*(prob[0]-0.5)); // For number (0,1)
// part[(iPart-iPart%N)/N][(iPart%N)].pos[iCoor] += (stepSize*(prob[0]/2)); // For symm random number
*/
///*
bool debugging = false;
if(debugging) {
// Debug movement
ECheckFlag = false;
for(int i=0; i<P; i++) {
part[i][1].pos[0] -= 1.0;
upToDate[i] = true;
}
}
else {
// Levy-Flight move
if(P<3) {
//cout << "Warning! You should not be using Levy-Flight with P < 3!" << endl;
}
ECheckFlag = false; // Check only against potential energy!
static int seed = -time(0);
vector <double> levyMean;
double levySigma;
int bead, beadm1;
vector <int> remainingPart;
for(int i=0; i<N; i++) {
remainingPart.push_back(i);
}
// Snip length must be at least 3 and shouldn't be more than P/2+1 or else you'll just collapse it
// snipLength-2 is the number of beads moved.
// int maxLevy = 30;
// int levyLength = min(static_cast<int>(prob[0]*(P-2)/2+1), maxLevy);
// *******************************************************
levyLength = levyNum;
// *******************************************************
int snipBegin = static_cast<int>(prob[levyModes]*P);
int snipEnd = (snipBegin+levyLength+1)%P;
int iPart, pickedPart;
for(int i=0; i<levyModes; i++) {
iPart = static_cast<int>((N-i-physics->lowFrozModes-physics->highFrozModes)*prob[i]);
//int pickedPart = int(iPart/P)+physics->lowFrozModes;
pickedPart = remainingPart[iPart+physics->lowFrozModes];
remainingPart.erase(remainingPart.begin()+iPart+physics->lowFrozModes);
//cout << "DES: PickedPart = " << pickedPart << endl;
/*
for(int i=0; i<N; i++) {
double tempAvg=0.0;
for(int j=0; j<P; j++) {
tempAvg+=part[j][i].pos[0];
}
tempAvg/=P;
cout << tempAvg << "\t";
}
cout << endl;
*/
// cout << "SnipBegin: " << snipBegin << "\tSnipEnd" << snipEnd << "\tSnipLength:" << snipLength << endl;
if(N > physics->lowFrozModes+physics->highFrozModes) {
for (int s=0; s<levyLength; s++) {
bead = (snipBegin+s+1)%P;
beadm1 = (snipBegin+s)%P;
levyMean = rho->GetLevyMean(part[beadm1][pickedPart], part[snipEnd][pickedPart], (double)(levyLength-s), epsMove, pickedPart);
levySigma = rho->GetLevySigma((double)(levyLength-s), epsMove, pickedPart) / sqrt(part[0][pickedPart].mass);
for(int k=0; k<coorDim; k++){
part[bead][pickedPart].pos[k] = RandomNum::rangau(levyMean[k], levySigma, &seed);
}
upToDate[bead] = false;
}
}
}
}
//*/
}
void TestSystem::Forget() {
oldEnergy = energy;
oldCheckVal = checkVal;
oldCarts = newCarts;
for(int i=0; i<P; i++) {
for(int j=0; j<N; j++) {
oldPart[i][j].pos = part[i][j].pos;
}
oldSliceAnharmonicV[i] = sliceAnharmonicV[i];
oldSliceCheck[i] = sliceCheck[i];
}
}
void TestSystem::Undo() {
energy = oldEnergy;
checkVal = oldCheckVal;
newCarts = oldCarts;
for(int i=0; i<P; i++) {
for(int j=0; j<N; j++) {
part[i][j].pos = oldPart[i][j].pos;
}
sliceAnharmonicV[i] = oldSliceAnharmonicV[i];
sliceCheck[i] = oldSliceCheck[i];
}
}
double TestSystem::Debug() {
return checkVal;
}
double TestSystem::GetHarmonicE() {
// cout << "Harmonic Energy is: " << harmonicE << endl;
return harmonicE;
}
void TestSystem::WritePartToFile(string pFileName) {
vector< vector<double> > averagePart = V->GetCoordUtil()->normalModeToCart(part[0]);
for(int i=1; i<part.size(); i++) {
vector< vector<double> > tempCarts = V->GetCoordUtil()->normalModeToCart(part[i]);
for(int j=0; j<averagePart.size(); j++) {
for(int k=0; k<averagePart[0].size(); k++) {
averagePart[j][k] += tempCarts[j][k];
}
}
}
for(int j=0; j<averagePart.size(); j++) {
for(int k=0; k<averagePart[0].size(); k++) {
averagePart[j][k] /= part.size();
}
}
ofstream pFile;
pFile.open(pFileName.c_str());
int dim = (int)averagePart[0].size();
if(dim>3){
cout << "Warning! Turn off write to file if dim > 3!!!!" << endl;
exit(-1);
}
else{
pFile << averagePart.size() << "\n" << endl;
for(int j=0; j<(int)averagePart.size(); j++) {
pFile << V->GetCoordUtil()->atomType[j] << "\t";
for(int k=0; k<dim; k++) {
pFile << averagePart[j][k] << "\t";
}
// For printing carts if dim == 2
for(int k=0; k<(3-dim); k++) {
pFile << 0 << "\t";
}
pFile << endl;
}
}
pFile.close();
}
string TestSystem::GetVType() {
return V->GetType();
}
string TestSystem::GetRhoType() {
return rho->GetType();
}
PhysicsUtil* TestSystem::GetPhysics() {
return physics;
}
string TestSystem::toString(int i) {
ostringstream convert;
convert << i;
return convert.str();
}