-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparams.h
145 lines (133 loc) · 3.86 KB
/
params.h
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
#ifndef PARAMS
#define PARAMS
#include <iostream>
#include "config_main.h"
#include "Vec2D.h"
struct Params
{
int cellNx;
int cellNy;
int AR;
double length;
int crossEval;
int nProc;
int nEquil;
int sweepEval;
double boxEdge;
double transFactor;
double angMag;
bool onefile;
double wallRatio;
Vec<double> box;
double cellWidth;
double molWidth;
double dr;
int Nx;
int Ny;
int nObj;
double transMag;
int nCell;
bool printUncross;
std::string shape;
Params(std::string cnfFile) {
ConfigFile prms(cnfFile);
Nx = prms.getValueOfKey<int>("Nx");
Ny = prms.getValueOfKey<int>("Ny");
cellNx = prms.getValueOfKey<int>("cellNx");
cellNy = prms.getValueOfKey<int>("cellNy");
AR = prms.getValueOfKey<int>("AR");
length = prms.getValueOfKey<double>("length");
crossEval = prms.getValueOfKey<int>("crossEval");
nEquil = prms.getValueOfKey<int>("nEquil");
nProc = prms.getValueOfKey<int>("nProc");
sweepEval = prms.getValueOfKey<int>("sweepEval");
boxEdge = prms.getValueOfKey<double>("boxEdge");
transFactor = prms.getValueOfKey<double>("transFactor");
angMag = prms.getValueOfKey<double>("angMag");
onefile = prms.getValueOfKey<int>("onefile");
printUncross = prms.getValueOfKey<bool>("printUncross");
shape = prms.getValueOfKey<std::string>("shape");
// box length defined as unity
if (cellNx > cellNy) {
int tmp = cellNx;
cellNx = cellNy;
cellNy = tmp;
};
wallRatio = cellNx / cellNy;
box.set_values(boxEdge*wallRatio, boxEdge);
cellWidth = boxEdge / cellNy;
molWidth = AR * length;
dr = (double) boxEdge/Nx;
//dr = (double)(cellWidth / sqrtDens);
nObj = Nx * Ny;
transMag = transFactor*dr;
nCell = cellNx * cellNy;
};
void writeParams(string fname) {
ofstream fout;
fout.open(fname, ios::out | ios::app | ios::binary);
if (!fout.is_open()) {
cout << "Could not open file for writing!" << endl;
return;
}
double rho = (double) nObj / (boxEdge*boxEdge);
double redRho = length*length*rho;
fout << "Nx " << Nx << "|"
<< "Ny " << Ny << "|"
<< "nObj " << nObj << "|"
<< "dr " << dr << "|"
<< "cellNx " << cellNx << "|"
<< "cellNy " << cellNy << "|"
<< "nCell " << nCell << "|"
<< "boxEdge " << boxEdge << "|"
<< "box.x " << box.x << "|"
<< "box.y " << box.y << "|"
<< "cellWidth " << cellWidth << "|"
<< "AR " << AR << "|"
<< "shape " << shape << "|"
<< "molWidth " << molWidth << "|"
<< "length " << length << "|"
<< "transFactor " << transFactor << "|"
<< "transMag " << transMag << "|"
<< "angMag " << angMag << "|"
<< "crossEval " << crossEval << "|"
<< "printUncross " << printUncross << "|"
<< "nEquil " << nEquil << "|"
<< "nProc " << nProc << "|"
<< "sweepEval " << sweepEval << "|"
<< "Rho " << rho << "|"
<< "ReducedRho " << redRho << endl;
fout.close();
}
void printParams() {
double rho = (double) nObj / (boxEdge*boxEdge);
double redRho = length*length*rho;
cout << "Nx " << Nx << endl
<< "Ny " << Ny << endl
<< "nObj " << nObj << endl
<< "dr " << dr << endl
<< "cellNx " << cellNx << endl
<< "cellNy " << cellNy << endl
<< "nCell " << nCell << endl
<< "boxEdge " << boxEdge << endl
<< "box.x " << box.x << endl
<< "box.y " << box.y << endl
<< "cellWidth " << cellWidth << endl
<< "AR " << AR << endl
<< "shape " << shape << endl
<< "molWidth " << molWidth << endl
<< "length " << length << endl
<< "transFactor " << transFactor << endl
<< "transMag " << transMag << endl
<< "angMag " << angMag << endl
<< "crossEval " << crossEval << endl
<< "printUncross " << printUncross << endl
<< "nEquil " << nEquil << endl
<< "nProc " << nProc << endl
<< "sweepEval " << sweepEval << endl
<< endl
<< "Rho " << rho << endl
<< "Reduced rho " << redRho << endl;
}
};
#endif