1 |
mmeineke |
377 |
#include <cstdlib> |
2 |
|
|
#include <cstring> |
3 |
|
|
|
4 |
|
|
|
5 |
|
|
#include "SimInfo.hpp" |
6 |
|
|
#define __C |
7 |
|
|
#include "fSimulation.h" |
8 |
|
|
#include "simError.h" |
9 |
|
|
|
10 |
|
|
#include "fortranWrappers.hpp" |
11 |
|
|
|
12 |
|
|
SimInfo* currentInfo; |
13 |
|
|
|
14 |
|
|
SimInfo::SimInfo(){ |
15 |
|
|
excludes = NULL; |
16 |
|
|
n_constraints = 0; |
17 |
|
|
n_oriented = 0; |
18 |
|
|
n_dipoles = 0; |
19 |
gezelter |
458 |
ndf = 0; |
20 |
|
|
ndfRaw = 0; |
21 |
mmeineke |
377 |
the_integrator = NULL; |
22 |
|
|
setTemp = 0; |
23 |
|
|
thermalTime = 0.0; |
24 |
mmeineke |
420 |
rCut = 0.0; |
25 |
mmeineke |
377 |
|
26 |
|
|
usePBC = 0; |
27 |
|
|
useLJ = 0; |
28 |
|
|
useSticky = 0; |
29 |
|
|
useDipole = 0; |
30 |
|
|
useReactionField = 0; |
31 |
|
|
useGB = 0; |
32 |
|
|
useEAM = 0; |
33 |
|
|
|
34 |
gezelter |
457 |
wrapMeSimInfo( this ); |
35 |
|
|
} |
36 |
mmeineke |
377 |
|
37 |
gezelter |
457 |
void SimInfo::setBox(double newBox[3]) { |
38 |
|
|
box_x = newBox[0]; |
39 |
|
|
box_y = newBox[1]; |
40 |
|
|
box_z = newBox[2]; |
41 |
|
|
setFortranBoxSize(newBox); |
42 |
|
|
} |
43 |
mmeineke |
377 |
|
44 |
gezelter |
457 |
void SimInfo::getBox(double theBox[3]) { |
45 |
|
|
theBox[0] = box_x; |
46 |
|
|
theBox[1] = box_y; |
47 |
|
|
theBox[2] = box_z; |
48 |
mmeineke |
377 |
} |
49 |
gezelter |
458 |
|
50 |
|
|
int SimInfo::getNDF(){ |
51 |
|
|
int ndf_local, ndf; |
52 |
gezelter |
457 |
|
53 |
gezelter |
458 |
ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints; |
54 |
|
|
|
55 |
|
|
#ifdef IS_MPI |
56 |
|
|
MPI_Allreduce(&ndf_local,&ndf,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
57 |
|
|
#else |
58 |
|
|
ndf = ndf_local; |
59 |
|
|
#endif |
60 |
|
|
|
61 |
|
|
ndf = ndf - 3; |
62 |
|
|
|
63 |
|
|
return ndf; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
int SimInfo::getNDFraw() { |
67 |
|
|
int ndfRaw_local, ndfRaw; |
68 |
|
|
|
69 |
|
|
// Raw degrees of freedom that we have to set |
70 |
|
|
ndfRaw_local = 3 * n_atoms + 3 * n_oriented; |
71 |
|
|
|
72 |
|
|
#ifdef IS_MPI |
73 |
|
|
MPI_Allreduce(&ndfRaw_local,&ndfRaw,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD); |
74 |
|
|
#else |
75 |
|
|
ndfRaw = ndfRaw_local; |
76 |
|
|
#endif |
77 |
|
|
|
78 |
|
|
return ndfRaw; |
79 |
|
|
} |
80 |
|
|
|
81 |
mmeineke |
377 |
void SimInfo::refreshSim(){ |
82 |
|
|
|
83 |
|
|
simtype fInfo; |
84 |
|
|
int isError; |
85 |
mmeineke |
424 |
int* excl; |
86 |
mmeineke |
377 |
|
87 |
|
|
fInfo.box[0] = box_x; |
88 |
|
|
fInfo.box[1] = box_y; |
89 |
|
|
fInfo.box[2] = box_z; |
90 |
|
|
|
91 |
|
|
fInfo.rlist = rList; |
92 |
|
|
fInfo.rcut = rCut; |
93 |
gezelter |
394 |
fInfo.rrf = ecr; |
94 |
|
|
fInfo.rt = ecr - est; |
95 |
mmeineke |
377 |
fInfo.dielect = dielectric; |
96 |
|
|
|
97 |
|
|
fInfo.SIM_uses_PBC = usePBC; |
98 |
mmeineke |
443 |
//fInfo.SIM_uses_LJ = 0; |
99 |
chuckv |
439 |
fInfo.SIM_uses_LJ = useLJ; |
100 |
mmeineke |
443 |
fInfo.SIM_uses_sticky = useSticky; |
101 |
|
|
//fInfo.SIM_uses_sticky = 0; |
102 |
gezelter |
394 |
fInfo.SIM_uses_dipoles = useDipole; |
103 |
mmeineke |
402 |
//fInfo.SIM_uses_dipoles = 0; |
104 |
mmeineke |
443 |
//fInfo.SIM_uses_RF = useReactionField; |
105 |
|
|
fInfo.SIM_uses_RF = 0; |
106 |
mmeineke |
377 |
fInfo.SIM_uses_GB = useGB; |
107 |
|
|
fInfo.SIM_uses_EAM = useEAM; |
108 |
|
|
|
109 |
mmeineke |
424 |
excl = Exclude::getArray(); |
110 |
mmeineke |
377 |
|
111 |
|
|
isError = 0; |
112 |
|
|
|
113 |
chuckv |
441 |
// fInfo; |
114 |
|
|
// n_atoms; |
115 |
|
|
// identArray; |
116 |
|
|
// n_exclude; |
117 |
|
|
// excludes; |
118 |
|
|
// nGlobalExcludes; |
119 |
|
|
// globalExcludes; |
120 |
|
|
// isError; |
121 |
mmeineke |
377 |
|
122 |
mmeineke |
424 |
setFsimulation( &fInfo, &n_atoms, identArray, &n_exclude, excl, |
123 |
|
|
&nGlobalExcludes, globalExcludes, &isError ); |
124 |
mmeineke |
377 |
|
125 |
|
|
if( isError ){ |
126 |
|
|
|
127 |
|
|
sprintf( painCave.errMsg, |
128 |
|
|
"There was an error setting the simulation information in fortran.\n" ); |
129 |
|
|
painCave.isFatal = 1; |
130 |
|
|
simError(); |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
#ifdef IS_MPI |
134 |
|
|
sprintf( checkPointMsg, |
135 |
|
|
"succesfully sent the simulation information to fortran.\n"); |
136 |
|
|
MPIcheckPoint(); |
137 |
|
|
#endif // is_mpi |
138 |
gezelter |
458 |
|
139 |
|
|
ndf = this->getNDF(); |
140 |
|
|
ndfRaw = this->getNDFraw(); |
141 |
|
|
|
142 |
mmeineke |
377 |
} |
143 |
|
|
|