ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/SimInfo.cpp
Revision: 463
Committed: Sat Apr 5 03:39:25 2003 UTC (21 years, 3 months ago) by gezelter
File size: 3758 byte(s)
Log Message:
Bug fixes for simulation module rewrites

File Contents

# User Rev Content
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 gezelter 463 double smallestBox, maxCutoff;
39     int status;
40 gezelter 457 box_x = newBox[0];
41     box_y = newBox[1];
42     box_z = newBox[2];
43     setFortranBoxSize(newBox);
44 gezelter 463
45     smallestBox = box_x;
46     if (box_y < smallestBox) smallestBox = box_y;
47     if (box_z < smallestBox) smallestBox = box_z;
48    
49     maxCutoff = smallestBox / 2.0;
50    
51     if (rList > maxCutoff) {
52     sprintf( painCave.errMsg,
53     "New Box size is forcing neighborlist radius down to %lf\n",
54     maxCutoff );
55     painCave.isFatal = 0;
56     simError();
57    
58     rList = maxCutoff;
59    
60     sprintf( painCave.errMsg,
61     "New Box size is forcing cutoff radius down to %lf\n",
62     maxCutoff - 1.0 );
63     painCave.isFatal = 0;
64     simError();
65    
66     rCut = rList - 1.0;
67    
68     // list radius changed so we have to refresh the simulation structure.
69     refreshSim();
70     }
71    
72     if (rCut > maxCutoff) {
73     sprintf( painCave.errMsg,
74     "New Box size is forcing cutoff radius down to %lf\n",
75     maxCutoff );
76     painCave.isFatal = 0;
77     simError();
78    
79     status = 0;
80     LJ_new_rcut(&rCut, &status);
81     if (status != 0) {
82     sprintf( painCave.errMsg,
83     "Error in recomputing LJ shifts based on new rcut\n");
84     painCave.isFatal = 1;
85     simError();
86     }
87     }
88 gezelter 457 }
89 mmeineke 377
90 gezelter 457 void SimInfo::getBox(double theBox[3]) {
91     theBox[0] = box_x;
92     theBox[1] = box_y;
93     theBox[2] = box_z;
94 mmeineke 377 }
95 gezelter 458
96     int SimInfo::getNDF(){
97     int ndf_local, ndf;
98 gezelter 457
99 gezelter 458 ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints;
100    
101     #ifdef IS_MPI
102     MPI_Allreduce(&ndf_local,&ndf,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
103     #else
104     ndf = ndf_local;
105     #endif
106    
107     ndf = ndf - 3;
108    
109     return ndf;
110     }
111    
112     int SimInfo::getNDFraw() {
113     int ndfRaw_local, ndfRaw;
114    
115     // Raw degrees of freedom that we have to set
116     ndfRaw_local = 3 * n_atoms + 3 * n_oriented;
117    
118     #ifdef IS_MPI
119     MPI_Allreduce(&ndfRaw_local,&ndfRaw,1,MPI_INT,MPI_SUM, MPI_COMM_WORLD);
120     #else
121     ndfRaw = ndfRaw_local;
122     #endif
123    
124     return ndfRaw;
125     }
126    
127 mmeineke 377 void SimInfo::refreshSim(){
128    
129     simtype fInfo;
130     int isError;
131 mmeineke 424 int* excl;
132 mmeineke 377
133     fInfo.box[0] = box_x;
134     fInfo.box[1] = box_y;
135     fInfo.box[2] = box_z;
136    
137     fInfo.rlist = rList;
138     fInfo.rcut = rCut;
139 gezelter 394 fInfo.rrf = ecr;
140     fInfo.rt = ecr - est;
141 mmeineke 377 fInfo.dielect = dielectric;
142    
143     fInfo.SIM_uses_PBC = usePBC;
144 mmeineke 443 //fInfo.SIM_uses_LJ = 0;
145 chuckv 439 fInfo.SIM_uses_LJ = useLJ;
146 mmeineke 443 fInfo.SIM_uses_sticky = useSticky;
147     //fInfo.SIM_uses_sticky = 0;
148 gezelter 394 fInfo.SIM_uses_dipoles = useDipole;
149 mmeineke 402 //fInfo.SIM_uses_dipoles = 0;
150 mmeineke 443 //fInfo.SIM_uses_RF = useReactionField;
151     fInfo.SIM_uses_RF = 0;
152 mmeineke 377 fInfo.SIM_uses_GB = useGB;
153     fInfo.SIM_uses_EAM = useEAM;
154    
155 mmeineke 424 excl = Exclude::getArray();
156 mmeineke 377
157     isError = 0;
158    
159 chuckv 441 // fInfo;
160     // n_atoms;
161     // identArray;
162     // n_exclude;
163     // excludes;
164     // nGlobalExcludes;
165     // globalExcludes;
166     // isError;
167 mmeineke 377
168 mmeineke 424 setFsimulation( &fInfo, &n_atoms, identArray, &n_exclude, excl,
169     &nGlobalExcludes, globalExcludes, &isError );
170 mmeineke 377
171     if( isError ){
172    
173     sprintf( painCave.errMsg,
174     "There was an error setting the simulation information in fortran.\n" );
175     painCave.isFatal = 1;
176     simError();
177     }
178    
179     #ifdef IS_MPI
180     sprintf( checkPointMsg,
181     "succesfully sent the simulation information to fortran.\n");
182     MPIcheckPoint();
183     #endif // is_mpi
184 gezelter 458
185     ndf = this->getNDF();
186     ndfRaw = this->getNDFraw();
187    
188 mmeineke 377 }
189