1 |
mmeineke |
10 |
#include <cstdlib> |
2 |
|
|
#include <iostream> |
3 |
|
|
#include <cmath> |
4 |
|
|
|
5 |
|
|
#include "SimSetup.hpp" |
6 |
|
|
#include "parse_me.h" |
7 |
|
|
#include "LRI.hpp" |
8 |
|
|
#include "Integrator.hpp" |
9 |
mmeineke |
144 |
|
10 |
chuckv |
131 |
#ifdef IS_MPI |
11 |
chuckv |
139 |
#include "mpiBASS.h" |
12 |
chuckv |
131 |
#include "bassDiag.hpp" |
13 |
|
|
#endif |
14 |
mmeineke |
10 |
|
15 |
|
|
SimSetup::SimSetup(){ |
16 |
|
|
stamps = new MakeStamps(); |
17 |
|
|
globals = new Globals(); |
18 |
|
|
} |
19 |
|
|
|
20 |
|
|
SimSetup::~SimSetup(){ |
21 |
|
|
delete stamps; |
22 |
|
|
delete globals; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
void SimSetup::parseFile( char* fileName ){ |
26 |
|
|
|
27 |
|
|
inFileName = fileName; |
28 |
|
|
set_interface_stamps( stamps, globals ); |
29 |
chuckv |
131 |
#ifdef IS_MPI |
30 |
chuckv |
124 |
mpiEventInit(); |
31 |
|
|
#endif |
32 |
mmeineke |
10 |
yacc_BASS( fileName ); |
33 |
chuckv |
131 |
#ifdef IS_MPI |
34 |
chuckv |
124 |
throwMPIEvent(NULL); |
35 |
|
|
#endif |
36 |
|
|
|
37 |
mmeineke |
10 |
} |
38 |
|
|
|
39 |
chuckv |
131 |
#ifdef IS_MPI |
40 |
chuckv |
124 |
void SimSetup::receiveParse(void){ |
41 |
|
|
|
42 |
|
|
set_interface_stamps( stamps, globals ); |
43 |
|
|
mpiEventInit(); |
44 |
|
|
mpiEventLoop(); |
45 |
|
|
|
46 |
|
|
} |
47 |
|
|
|
48 |
chuckv |
131 |
|
49 |
chuckv |
128 |
void SimSetup::testMe(void){ |
50 |
|
|
bassDiag* dumpMe = new bassDiag(globals,stamps); |
51 |
|
|
dumpMe->dumpStamps(); |
52 |
|
|
delete dumpMe; |
53 |
|
|
} |
54 |
chuckv |
131 |
#endif |
55 |
mmeineke |
10 |
void SimSetup::createSim( void ){ |
56 |
|
|
|
57 |
|
|
MakeStamps *the_stamps; |
58 |
|
|
Globals* the_globals; |
59 |
|
|
int i; |
60 |
|
|
|
61 |
|
|
// get the stamps and globals; |
62 |
|
|
the_stamps = stamps; |
63 |
|
|
the_globals = globals; |
64 |
|
|
|
65 |
|
|
// set the easy ones first |
66 |
|
|
simnfo->target_temp = the_globals->getTargetTemp(); |
67 |
|
|
simnfo->dt = the_globals->getDt(); |
68 |
|
|
simnfo->run_time = the_globals->getRunTime(); |
69 |
|
|
|
70 |
|
|
// get the ones we know are there, yet still may need some work. |
71 |
|
|
n_components = the_globals->getNComponents(); |
72 |
|
|
strcpy( force_field, the_globals->getForceField() ); |
73 |
|
|
strcpy( ensemble, the_globals->getEnsemble() ); |
74 |
chuckv |
124 |
|
75 |
mmeineke |
10 |
if( !strcmp( force_field, "TraPPE" ) ) the_ff = new TraPPEFF(); |
76 |
|
|
else if( !strcmp( force_field, "DipoleTest" ) ) the_ff = new DipoleTestFF(); |
77 |
|
|
else if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF(); |
78 |
|
|
else{ |
79 |
chuckv |
124 |
std::cerr<< "SimSetup Error. Unrecognized force field -> " |
80 |
mmeineke |
10 |
<< force_field << "\n"; |
81 |
|
|
exit(8); |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
// get the components and calculate the tot_nMol and indvidual n_mol |
85 |
|
|
the_components = the_globals->getComponents(); |
86 |
|
|
components_nmol = new int[n_components]; |
87 |
|
|
comp_stamps = new MoleculeStamp*[n_components]; |
88 |
chuckv |
124 |
|
89 |
mmeineke |
10 |
if( !the_globals->haveNMol() ){ |
90 |
chuckv |
124 |
// we don't have the total number of molecules, so we assume it is |
91 |
mmeineke |
10 |
// given in each component |
92 |
|
|
|
93 |
|
|
tot_nmol = 0; |
94 |
|
|
for( i=0; i<n_components; i++ ){ |
95 |
chuckv |
124 |
|
96 |
mmeineke |
10 |
if( !the_components[i]->haveNMol() ){ |
97 |
|
|
// we have a problem |
98 |
|
|
std::cerr << "SimSetup Error. No global NMol or component NMol" |
99 |
|
|
<< " given. Cannot calculate the number of atoms.\n"; |
100 |
|
|
exit( 8 ); |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
tot_nmol += the_components[i]->getNMol(); |
104 |
|
|
components_nmol[i] = the_components[i]->getNMol(); |
105 |
|
|
} |
106 |
|
|
} |
107 |
|
|
else{ |
108 |
|
|
std::cerr << "NOT A SUPPORTED FEATURE\n"; |
109 |
chuckv |
124 |
|
110 |
mmeineke |
10 |
// tot_nmol = the_globals->getNMol(); |
111 |
chuckv |
124 |
|
112 |
mmeineke |
10 |
// //we have the total number of molecules, now we check for molfractions |
113 |
|
|
// for( i=0; i<n_components; i++ ){ |
114 |
chuckv |
124 |
|
115 |
mmeineke |
10 |
// if( !the_components[i]->haveMolFraction() ){ |
116 |
chuckv |
124 |
|
117 |
mmeineke |
10 |
// if( !the_components[i]->haveNMol() ){ |
118 |
|
|
// //we have a problem |
119 |
|
|
// std::cerr << "SimSetup error. Neither molFraction nor " |
120 |
|
|
// << " nMol was given in component |
121 |
|
|
|
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
// make an array of molecule stamps that match the components used. |
125 |
|
|
|
126 |
|
|
for( i=0; i<n_components; i++ ){ |
127 |
|
|
|
128 |
chuckv |
124 |
comp_stamps[i] = |
129 |
mmeineke |
10 |
the_stamps->getMolecule( the_components[i]->getType() ); |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
|
133 |
chuckv |
124 |
|
134 |
mmeineke |
10 |
// caclulate the number of atoms, bonds, bends and torsions |
135 |
|
|
|
136 |
|
|
tot_atoms = 0; |
137 |
|
|
tot_bonds = 0; |
138 |
|
|
tot_bends = 0; |
139 |
|
|
tot_torsions = 0; |
140 |
|
|
for( i=0; i<n_components; i++ ){ |
141 |
chuckv |
124 |
|
142 |
mmeineke |
10 |
tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
143 |
|
|
tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
144 |
|
|
tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
145 |
|
|
tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); |
146 |
|
|
} |
147 |
chuckv |
124 |
|
148 |
mmeineke |
10 |
tot_SRI = tot_bonds + tot_bends + tot_torsions; |
149 |
chuckv |
124 |
|
150 |
mmeineke |
10 |
simnfo->n_atoms = tot_atoms; |
151 |
|
|
simnfo->n_bonds = tot_bonds; |
152 |
|
|
simnfo->n_bends = tot_bends; |
153 |
|
|
simnfo->n_torsions = tot_torsions; |
154 |
|
|
simnfo->n_SRI = tot_SRI; |
155 |
|
|
|
156 |
|
|
// create the atom and short range interaction arrays |
157 |
chuckv |
124 |
|
158 |
mmeineke |
10 |
the_atoms = new Atom*[tot_atoms]; |
159 |
mmeineke |
145 |
Atom::createArrays(tot_atoms); |
160 |
mmeineke |
113 |
the_molecules = new Molecule[tot_nmol]; |
161 |
chuckv |
124 |
|
162 |
|
|
|
163 |
mmeineke |
10 |
if( tot_SRI ){ |
164 |
|
|
the_sris = new SRI*[tot_SRI]; |
165 |
|
|
the_excludes = new ex_pair[tot_SRI]; |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
// set the arrays into the SimInfo object |
169 |
|
|
|
170 |
|
|
simnfo->atoms = the_atoms; |
171 |
|
|
simnfo->sr_interactions = the_sris; |
172 |
|
|
simnfo->n_exclude = tot_SRI; |
173 |
|
|
simnfo->excludes = the_excludes; |
174 |
|
|
|
175 |
chuckv |
124 |
|
176 |
mmeineke |
10 |
// initialize the arrays |
177 |
chuckv |
124 |
|
178 |
mmeineke |
10 |
the_ff->setSimInfo( simnfo ); |
179 |
chuckv |
124 |
|
180 |
mmeineke |
10 |
makeAtoms(); |
181 |
|
|
|
182 |
|
|
if( tot_bonds ){ |
183 |
|
|
makeBonds(); |
184 |
|
|
} |
185 |
|
|
|
186 |
|
|
if( tot_bends ){ |
187 |
|
|
makeBends(); |
188 |
|
|
} |
189 |
|
|
|
190 |
|
|
if( tot_torsions ){ |
191 |
|
|
makeTorsions(); |
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
// makeMolecules(); |
195 |
|
|
|
196 |
|
|
// get some of the tricky things that may still be in the globals |
197 |
|
|
|
198 |
|
|
if( simnfo->n_dipoles ){ |
199 |
|
|
|
200 |
|
|
if( !the_globals->haveRRF() ){ |
201 |
|
|
std::cerr << "SimSetup Error, system has dipoles, but no rRF was set.\n"; |
202 |
|
|
exit(8); |
203 |
|
|
} |
204 |
|
|
if( !the_globals->haveDielectric() ){ |
205 |
|
|
std::cerr << "SimSetup Error, system has dipoles, but no" |
206 |
|
|
<< " dielectric was set.\n"; |
207 |
|
|
exit(8); |
208 |
|
|
} |
209 |
|
|
|
210 |
|
|
simnfo->rRF = the_globals->getRRF(); |
211 |
|
|
simnfo->dielectric = the_globals->getDielectric(); |
212 |
|
|
} |
213 |
|
|
|
214 |
|
|
if( the_globals->haveBox() ){ |
215 |
|
|
simnfo->box_x = the_globals->getBox(); |
216 |
|
|
simnfo->box_y = the_globals->getBox(); |
217 |
|
|
simnfo->box_z = the_globals->getBox(); |
218 |
|
|
} |
219 |
|
|
else if( the_globals->haveDensity() ){ |
220 |
chuckv |
124 |
|
221 |
mmeineke |
10 |
double vol; |
222 |
|
|
vol = (double)tot_nmol / the_globals->getDensity(); |
223 |
|
|
simnfo->box_x = pow( vol, ( 1.0 / 3.0 ) ); |
224 |
|
|
simnfo->box_y = simnfo->box_x; |
225 |
|
|
simnfo->box_z = simnfo->box_x; |
226 |
|
|
} |
227 |
|
|
else{ |
228 |
|
|
if( !the_globals->haveBoxX() ){ |
229 |
|
|
std::cerr << "SimSetup error, no periodic BoxX size given.\n"; |
230 |
|
|
exit(8); |
231 |
|
|
} |
232 |
|
|
simnfo->box_x = the_globals->getBoxX(); |
233 |
|
|
|
234 |
|
|
if( !the_globals->haveBoxY() ){ |
235 |
|
|
std::cerr << "SimSetup error, no periodic BoxY size given.\n"; |
236 |
|
|
exit(8); |
237 |
|
|
} |
238 |
|
|
simnfo->box_y = the_globals->getBoxY(); |
239 |
|
|
|
240 |
|
|
if( !the_globals->haveBoxZ() ){ |
241 |
|
|
std::cerr << "SimSetup error, no periodic BoxZ size given.\n"; |
242 |
|
|
exit(8); |
243 |
|
|
} |
244 |
|
|
simnfo->box_z = the_globals->getBoxZ(); |
245 |
|
|
} |
246 |
|
|
|
247 |
chuckv |
124 |
|
248 |
|
|
// if( the_globals->haveInitialConfig() ){ |
249 |
|
|
// InitializeFromFile* fileInit; |
250 |
|
|
// fileInit = new InitializeFromFile( the_globals->getInitialConfig() ); |
251 |
|
|
|
252 |
|
|
// fileInit->read_xyz( simnfo ); // default velocities on |
253 |
|
|
|
254 |
|
|
// delete fileInit; |
255 |
|
|
// } |
256 |
|
|
// else{ |
257 |
|
|
|
258 |
mmeineke |
10 |
initFromBass(); |
259 |
|
|
|
260 |
|
|
|
261 |
chuckv |
124 |
// } |
262 |
|
|
|
263 |
|
|
// if( the_globals->haveFinalConfig() ){ |
264 |
|
|
// strcpy( simnfo->finalName, the_globals->getFinalConfig() ); |
265 |
|
|
// } |
266 |
|
|
// else{ |
267 |
|
|
// strcpy( simnfo->finalName, inFileName ); |
268 |
|
|
// char* endTest; |
269 |
|
|
// int nameLength = strlen( simnfo->finalName ); |
270 |
|
|
// endTest = &(simnfo->finalName[nameLength - 5]); |
271 |
|
|
// if( !strcmp( endTest, ".bass" ) ){ |
272 |
|
|
// strcpy( endTest, ".eor" ); |
273 |
|
|
// } |
274 |
|
|
// else if( !strcmp( endTest, ".BASS" ) ){ |
275 |
|
|
// strcpy( endTest, ".eor" ); |
276 |
|
|
// } |
277 |
|
|
// else{ |
278 |
|
|
// endTest = &(simnfo->finalName[nameLength - 4]); |
279 |
|
|
// if( !strcmp( endTest, ".bss" ) ){ |
280 |
|
|
// strcpy( endTest, ".eor" ); |
281 |
|
|
// } |
282 |
|
|
// else if( !strcmp( endTest, ".mdl" ) ){ |
283 |
|
|
// strcpy( endTest, ".eor" ); |
284 |
|
|
// } |
285 |
|
|
// else{ |
286 |
|
|
// strcat( simnfo->finalName, ".eor" ); |
287 |
|
|
// } |
288 |
|
|
// } |
289 |
|
|
// } |
290 |
|
|
|
291 |
|
|
// // make the sample and status out names |
292 |
|
|
|
293 |
|
|
// strcpy( simnfo->sampleName, inFileName ); |
294 |
|
|
// char* endTest; |
295 |
|
|
// int nameLength = strlen( simnfo->sampleName ); |
296 |
|
|
// endTest = &(simnfo->sampleName[nameLength - 5]); |
297 |
|
|
// if( !strcmp( endTest, ".bass" ) ){ |
298 |
|
|
// strcpy( endTest, ".dump" ); |
299 |
|
|
// } |
300 |
|
|
// else if( !strcmp( endTest, ".BASS" ) ){ |
301 |
|
|
// strcpy( endTest, ".dump" ); |
302 |
|
|
// } |
303 |
|
|
// else{ |
304 |
|
|
// endTest = &(simnfo->sampleName[nameLength - 4]); |
305 |
|
|
// if( !strcmp( endTest, ".bss" ) ){ |
306 |
|
|
// strcpy( endTest, ".dump" ); |
307 |
|
|
// } |
308 |
|
|
// else if( !strcmp( endTest, ".mdl" ) ){ |
309 |
|
|
// strcpy( endTest, ".dump" ); |
310 |
|
|
// } |
311 |
|
|
// else{ |
312 |
|
|
// strcat( simnfo->sampleName, ".dump" ); |
313 |
|
|
// } |
314 |
|
|
// } |
315 |
|
|
|
316 |
|
|
// strcpy( simnfo->statusName, inFileName ); |
317 |
|
|
// nameLength = strlen( simnfo->statusName ); |
318 |
|
|
// endTest = &(simnfo->statusName[nameLength - 5]); |
319 |
|
|
// if( !strcmp( endTest, ".bass" ) ){ |
320 |
|
|
// strcpy( endTest, ".stat" ); |
321 |
|
|
// } |
322 |
|
|
// else if( !strcmp( endTest, ".BASS" ) ){ |
323 |
|
|
// strcpy( endTest, ".stat" ); |
324 |
|
|
// } |
325 |
|
|
// else{ |
326 |
|
|
// endTest = &(simnfo->statusName[nameLength - 4]); |
327 |
|
|
// if( !strcmp( endTest, ".bss" ) ){ |
328 |
|
|
// strcpy( endTest, ".stat" ); |
329 |
|
|
// } |
330 |
|
|
// else if( !strcmp( endTest, ".mdl" ) ){ |
331 |
|
|
// strcpy( endTest, ".stat" ); |
332 |
|
|
// } |
333 |
|
|
// else{ |
334 |
|
|
// strcat( simnfo->statusName, ".stat" ); |
335 |
|
|
// } |
336 |
|
|
// } |
337 |
|
|
|
338 |
|
|
|
339 |
mmeineke |
10 |
// set the status, sample, and themal kick times |
340 |
|
|
|
341 |
|
|
if( the_globals->haveSampleTime() ){ |
342 |
chuckv |
124 |
simnfo->sampleTime = the_globals->getSampleTime(); |
343 |
mmeineke |
10 |
simnfo->statusTime = simnfo->sampleTime; |
344 |
|
|
simnfo->thermalTime = simnfo->sampleTime; |
345 |
|
|
} |
346 |
|
|
else{ |
347 |
chuckv |
124 |
simnfo->sampleTime = the_globals->getRunTime(); |
348 |
mmeineke |
10 |
simnfo->statusTime = simnfo->sampleTime; |
349 |
|
|
simnfo->thermalTime = simnfo->sampleTime; |
350 |
|
|
} |
351 |
|
|
|
352 |
|
|
if( the_globals->haveStatusTime() ){ |
353 |
|
|
simnfo->statusTime = the_globals->getStatusTime(); |
354 |
|
|
} |
355 |
|
|
|
356 |
|
|
if( the_globals->haveThermalTime() ){ |
357 |
|
|
simnfo->thermalTime = the_globals->getThermalTime(); |
358 |
|
|
} |
359 |
|
|
|
360 |
|
|
// check for the temperature set flag |
361 |
|
|
|
362 |
|
|
if( the_globals->haveTempSet() ) simnfo->setTemp = the_globals->getTempSet(); |
363 |
chuckv |
124 |
|
364 |
|
|
|
365 |
mmeineke |
10 |
// make the longe range forces and the integrator |
366 |
chuckv |
124 |
|
367 |
mmeineke |
10 |
new AllLong( simnfo ); |
368 |
chuckv |
124 |
|
369 |
mmeineke |
10 |
if( !strcmp( force_field, "TraPPE" ) ) new Verlet( *simnfo ); |
370 |
|
|
if( !strcmp( force_field, "DipoleTest" ) ) new Symplectic( simnfo ); |
371 |
|
|
if( !strcmp( force_field, "TraPPE_Ex" ) ) new Symplectic( simnfo ); |
372 |
|
|
} |
373 |
|
|
|
374 |
|
|
void SimSetup::makeAtoms( void ){ |
375 |
chuckv |
124 |
|
376 |
mmeineke |
10 |
int i, j, k, index; |
377 |
|
|
double ux, uy, uz, uSqr, u; |
378 |
|
|
AtomStamp* current_atom; |
379 |
|
|
DirectionalAtom* dAtom; |
380 |
mmeineke |
117 |
int molIndex, molStart, molEnd, nMemb; |
381 |
mmeineke |
10 |
|
382 |
chuckv |
124 |
|
383 |
mmeineke |
117 |
molIndex = 0; |
384 |
mmeineke |
10 |
index = 0; |
385 |
|
|
for( i=0; i<n_components; i++ ){ |
386 |
chuckv |
124 |
|
387 |
mmeineke |
10 |
for( j=0; j<components_nmol[i]; j++ ){ |
388 |
chuckv |
124 |
|
389 |
mmeineke |
117 |
molStart = index; |
390 |
|
|
nMemb = comp_stamps[i]->getNAtoms(); |
391 |
mmeineke |
10 |
for( k=0; k<comp_stamps[i]->getNAtoms(); k++ ){ |
392 |
chuckv |
124 |
|
393 |
mmeineke |
10 |
current_atom = comp_stamps[i]->getAtom( k ); |
394 |
chuckv |
124 |
if( current_atom->haveOrientation() ){ |
395 |
mmeineke |
10 |
|
396 |
mmeineke |
145 |
dAtom = new DirectionalAtom(index); |
397 |
mmeineke |
10 |
simnfo->n_oriented++; |
398 |
|
|
the_atoms[index] = dAtom; |
399 |
chuckv |
124 |
|
400 |
mmeineke |
10 |
ux = current_atom->getOrntX(); |
401 |
|
|
uy = current_atom->getOrntY(); |
402 |
|
|
uz = current_atom->getOrntZ(); |
403 |
chuckv |
124 |
|
404 |
mmeineke |
10 |
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
405 |
chuckv |
124 |
|
406 |
mmeineke |
10 |
u = sqrt( uSqr ); |
407 |
|
|
ux = ux / u; |
408 |
|
|
uy = uy / u; |
409 |
|
|
uz = uz / u; |
410 |
chuckv |
124 |
|
411 |
mmeineke |
10 |
dAtom->setSUx( ux ); |
412 |
|
|
dAtom->setSUy( uy ); |
413 |
|
|
dAtom->setSUz( uz ); |
414 |
|
|
} |
415 |
|
|
else{ |
416 |
mmeineke |
145 |
the_atoms[index] = new GeneralAtom(index); |
417 |
mmeineke |
10 |
} |
418 |
|
|
the_atoms[index]->setType( current_atom->getType() ); |
419 |
|
|
the_atoms[index]->setIndex( index ); |
420 |
chuckv |
124 |
|
421 |
mmeineke |
10 |
// increment the index and repeat; |
422 |
|
|
index++; |
423 |
|
|
} |
424 |
chuckv |
124 |
|
425 |
mmeineke |
117 |
molEnd = index -1; |
426 |
|
|
the_molecules[molIndex].setNMembers( nMemb ); |
427 |
|
|
the_molecules[molIndex].setStartAtom( molStart ); |
428 |
|
|
the_molecules[molIndex].setEndAtom( molEnd ); |
429 |
|
|
molIndex++; |
430 |
|
|
|
431 |
mmeineke |
10 |
} |
432 |
|
|
} |
433 |
chuckv |
124 |
|
434 |
mmeineke |
10 |
the_ff->initializeAtoms(); |
435 |
|
|
} |
436 |
|
|
|
437 |
|
|
void SimSetup::makeBonds( void ){ |
438 |
|
|
|
439 |
|
|
int i, j, k, index, offset; |
440 |
|
|
bond_pair* the_bonds; |
441 |
|
|
BondStamp* current_bond; |
442 |
|
|
|
443 |
|
|
the_bonds = new bond_pair[tot_bonds]; |
444 |
|
|
index = 0; |
445 |
|
|
offset = 0; |
446 |
|
|
for( i=0; i<n_components; i++ ){ |
447 |
chuckv |
124 |
|
448 |
mmeineke |
10 |
for( j=0; j<components_nmol[i]; j++ ){ |
449 |
chuckv |
124 |
|
450 |
mmeineke |
10 |
for( k=0; k<comp_stamps[i]->getNBonds(); k++ ){ |
451 |
chuckv |
124 |
|
452 |
mmeineke |
10 |
current_bond = comp_stamps[i]->getBond( k ); |
453 |
|
|
the_bonds[index].a = current_bond->getA() + offset; |
454 |
|
|
the_bonds[index].b = current_bond->getB() + offset; |
455 |
|
|
|
456 |
|
|
the_excludes[index].i = the_bonds[index].a; |
457 |
|
|
the_excludes[index].j = the_bonds[index].b; |
458 |
|
|
|
459 |
|
|
// increment the index and repeat; |
460 |
|
|
index++; |
461 |
|
|
} |
462 |
|
|
offset += comp_stamps[i]->getNAtoms(); |
463 |
|
|
} |
464 |
|
|
} |
465 |
chuckv |
124 |
|
466 |
mmeineke |
10 |
the_ff->initializeBonds( the_bonds ); |
467 |
|
|
} |
468 |
|
|
|
469 |
|
|
void SimSetup::makeBends( void ){ |
470 |
|
|
|
471 |
|
|
int i, j, k, index, offset; |
472 |
|
|
bend_set* the_bends; |
473 |
|
|
BendStamp* current_bend; |
474 |
|
|
|
475 |
|
|
the_bends = new bend_set[tot_bends]; |
476 |
|
|
index = 0; |
477 |
|
|
offset = 0; |
478 |
|
|
for( i=0; i<n_components; i++ ){ |
479 |
chuckv |
124 |
|
480 |
mmeineke |
10 |
for( j=0; j<components_nmol[i]; j++ ){ |
481 |
chuckv |
124 |
|
482 |
mmeineke |
10 |
for( k=0; k<comp_stamps[i]->getNBends(); k++ ){ |
483 |
chuckv |
124 |
|
484 |
mmeineke |
10 |
current_bend = comp_stamps[i]->getBend( k ); |
485 |
|
|
the_bends[index].a = current_bend->getA() + offset; |
486 |
|
|
the_bends[index].b = current_bend->getB() + offset; |
487 |
|
|
the_bends[index].c = current_bend->getC() + offset; |
488 |
|
|
|
489 |
|
|
the_excludes[index + tot_bonds].i = the_bends[index].a; |
490 |
|
|
the_excludes[index + tot_bonds].j = the_bends[index].c; |
491 |
|
|
|
492 |
|
|
// increment the index and repeat; |
493 |
|
|
index++; |
494 |
|
|
} |
495 |
|
|
offset += comp_stamps[i]->getNAtoms(); |
496 |
|
|
} |
497 |
|
|
} |
498 |
chuckv |
124 |
|
499 |
mmeineke |
10 |
the_ff->initializeBends( the_bends ); |
500 |
|
|
} |
501 |
|
|
|
502 |
|
|
void SimSetup::makeTorsions( void ){ |
503 |
|
|
|
504 |
|
|
int i, j, k, index, offset; |
505 |
|
|
torsion_set* the_torsions; |
506 |
|
|
TorsionStamp* current_torsion; |
507 |
|
|
|
508 |
|
|
the_torsions = new torsion_set[tot_torsions]; |
509 |
|
|
index = 0; |
510 |
|
|
offset = 0; |
511 |
|
|
for( i=0; i<n_components; i++ ){ |
512 |
chuckv |
124 |
|
513 |
mmeineke |
10 |
for( j=0; j<components_nmol[i]; j++ ){ |
514 |
chuckv |
124 |
|
515 |
mmeineke |
10 |
for( k=0; k<comp_stamps[i]->getNTorsions(); k++ ){ |
516 |
chuckv |
124 |
|
517 |
mmeineke |
10 |
current_torsion = comp_stamps[i]->getTorsion( k ); |
518 |
|
|
the_torsions[index].a = current_torsion->getA() + offset; |
519 |
|
|
the_torsions[index].b = current_torsion->getB() + offset; |
520 |
|
|
the_torsions[index].c = current_torsion->getC() + offset; |
521 |
|
|
the_torsions[index].d = current_torsion->getD() + offset; |
522 |
|
|
|
523 |
|
|
the_excludes[index + tot_bonds + tot_bends].i = the_torsions[index].a; |
524 |
|
|
the_excludes[index + tot_bonds + tot_bends].j = the_torsions[index].d; |
525 |
|
|
|
526 |
|
|
// increment the index and repeat; |
527 |
|
|
index++; |
528 |
|
|
} |
529 |
|
|
offset += comp_stamps[i]->getNAtoms(); |
530 |
|
|
} |
531 |
|
|
} |
532 |
chuckv |
124 |
|
533 |
mmeineke |
10 |
the_ff->initializeTorsions( the_torsions ); |
534 |
|
|
} |
535 |
|
|
|
536 |
|
|
void SimSetup::initFromBass( void ){ |
537 |
|
|
|
538 |
|
|
int i, j, k; |
539 |
|
|
int n_cells; |
540 |
|
|
double cellx, celly, cellz; |
541 |
|
|
double temp1, temp2, temp3; |
542 |
|
|
int n_per_extra; |
543 |
|
|
int n_extra; |
544 |
|
|
int have_extra, done; |
545 |
|
|
|
546 |
|
|
temp1 = (double)tot_nmol / 4.0; |
547 |
|
|
temp2 = pow( temp1, ( 1.0 / 3.0 ) ); |
548 |
|
|
temp3 = ceil( temp2 ); |
549 |
|
|
|
550 |
|
|
have_extra =0; |
551 |
|
|
if( temp2 < temp3 ){ // we have a non-complete lattice |
552 |
|
|
have_extra =1; |
553 |
|
|
|
554 |
|
|
n_cells = (int)temp3 - 1; |
555 |
|
|
cellx = simnfo->box_x / temp3; |
556 |
|
|
celly = simnfo->box_y / temp3; |
557 |
|
|
cellz = simnfo->box_z / temp3; |
558 |
|
|
n_extra = tot_nmol - ( 4 * n_cells * n_cells * n_cells ); |
559 |
|
|
temp1 = ((double)n_extra) / ( pow( temp3, 3.0 ) - pow( n_cells, 3.0 ) ); |
560 |
|
|
n_per_extra = (int)ceil( temp1 ); |
561 |
|
|
|
562 |
|
|
if( n_per_extra > 4){ |
563 |
|
|
std::cerr << "THere has been an error in constructing the non-complete lattice.\n"; |
564 |
|
|
exit(8); |
565 |
|
|
} |
566 |
|
|
} |
567 |
|
|
else{ |
568 |
|
|
n_cells = (int)temp3; |
569 |
|
|
cellx = simnfo->box_x / temp3; |
570 |
|
|
celly = simnfo->box_y / temp3; |
571 |
|
|
cellz = simnfo->box_z / temp3; |
572 |
|
|
} |
573 |
chuckv |
124 |
|
574 |
mmeineke |
10 |
current_mol = 0; |
575 |
|
|
current_comp_mol = 0; |
576 |
|
|
current_comp = 0; |
577 |
|
|
current_atom_ndx = 0; |
578 |
chuckv |
124 |
|
579 |
mmeineke |
10 |
for( i=0; i < n_cells ; i++ ){ |
580 |
|
|
for( j=0; j < n_cells; j++ ){ |
581 |
|
|
for( k=0; k < n_cells; k++ ){ |
582 |
chuckv |
124 |
|
583 |
mmeineke |
10 |
makeElement( i * cellx, |
584 |
|
|
j * celly, |
585 |
|
|
k * cellz ); |
586 |
chuckv |
124 |
|
587 |
mmeineke |
10 |
makeElement( i * cellx + 0.5 * cellx, |
588 |
|
|
j * celly + 0.5 * celly, |
589 |
|
|
k * cellz ); |
590 |
chuckv |
124 |
|
591 |
mmeineke |
10 |
makeElement( i * cellx, |
592 |
|
|
j * celly + 0.5 * celly, |
593 |
|
|
k * cellz + 0.5 * cellz ); |
594 |
chuckv |
124 |
|
595 |
mmeineke |
10 |
makeElement( i * cellx + 0.5 * cellx, |
596 |
|
|
j * celly, |
597 |
|
|
k * cellz + 0.5 * cellz ); |
598 |
|
|
} |
599 |
|
|
} |
600 |
|
|
} |
601 |
|
|
|
602 |
|
|
if( have_extra ){ |
603 |
|
|
done = 0; |
604 |
chuckv |
124 |
|
605 |
mmeineke |
10 |
int start_ndx; |
606 |
|
|
for( i=0; i < (n_cells+1) && !done; i++ ){ |
607 |
|
|
for( j=0; j < (n_cells+1) && !done; j++ ){ |
608 |
chuckv |
124 |
|
609 |
mmeineke |
10 |
if( i < n_cells ){ |
610 |
chuckv |
124 |
|
611 |
mmeineke |
10 |
if( j < n_cells ){ |
612 |
|
|
start_ndx = n_cells; |
613 |
|
|
} |
614 |
|
|
else start_ndx = 0; |
615 |
|
|
} |
616 |
|
|
else start_ndx = 0; |
617 |
chuckv |
124 |
|
618 |
mmeineke |
10 |
for( k=start_ndx; k < (n_cells+1) && !done; k++ ){ |
619 |
chuckv |
124 |
|
620 |
mmeineke |
10 |
makeElement( i * cellx, |
621 |
|
|
j * celly, |
622 |
|
|
k * cellz ); |
623 |
|
|
done = ( current_mol >= tot_nmol ); |
624 |
chuckv |
124 |
|
625 |
mmeineke |
10 |
if( !done && n_per_extra > 1 ){ |
626 |
|
|
makeElement( i * cellx + 0.5 * cellx, |
627 |
|
|
j * celly + 0.5 * celly, |
628 |
|
|
k * cellz ); |
629 |
|
|
done = ( current_mol >= tot_nmol ); |
630 |
|
|
} |
631 |
chuckv |
124 |
|
632 |
mmeineke |
10 |
if( !done && n_per_extra > 2){ |
633 |
|
|
makeElement( i * cellx, |
634 |
|
|
j * celly + 0.5 * celly, |
635 |
|
|
k * cellz + 0.5 * cellz ); |
636 |
|
|
done = ( current_mol >= tot_nmol ); |
637 |
|
|
} |
638 |
chuckv |
124 |
|
639 |
mmeineke |
10 |
if( !done && n_per_extra > 3){ |
640 |
|
|
makeElement( i * cellx + 0.5 * cellx, |
641 |
|
|
j * celly, |
642 |
|
|
k * cellz + 0.5 * cellz ); |
643 |
|
|
done = ( current_mol >= tot_nmol ); |
644 |
|
|
} |
645 |
|
|
} |
646 |
|
|
} |
647 |
|
|
} |
648 |
|
|
} |
649 |
chuckv |
124 |
|
650 |
|
|
|
651 |
mmeineke |
10 |
for( i=0; i<simnfo->n_atoms; i++ ){ |
652 |
|
|
simnfo->atoms[i]->set_vx( 0.0 ); |
653 |
|
|
simnfo->atoms[i]->set_vy( 0.0 ); |
654 |
|
|
simnfo->atoms[i]->set_vz( 0.0 ); |
655 |
|
|
} |
656 |
|
|
} |
657 |
|
|
|
658 |
|
|
void SimSetup::makeElement( double x, double y, double z ){ |
659 |
|
|
|
660 |
|
|
int k; |
661 |
|
|
AtomStamp* current_atom; |
662 |
|
|
DirectionalAtom* dAtom; |
663 |
|
|
double rotMat[3][3]; |
664 |
|
|
|
665 |
|
|
for( k=0; k<comp_stamps[current_comp]->getNAtoms(); k++ ){ |
666 |
chuckv |
124 |
|
667 |
mmeineke |
10 |
current_atom = comp_stamps[current_comp]->getAtom( k ); |
668 |
|
|
if( !current_atom->havePosition() ){ |
669 |
|
|
std::cerr << "Component " << comp_stamps[current_comp]->getID() |
670 |
|
|
<< ", atom " << current_atom->getType() |
671 |
|
|
<< " does not have a position specified.\n" |
672 |
|
|
<< "The initialization routine is unable to give a start" |
673 |
|
|
<< " position.\n"; |
674 |
|
|
exit(8); |
675 |
|
|
} |
676 |
chuckv |
124 |
|
677 |
mmeineke |
10 |
the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() ); |
678 |
|
|
the_atoms[current_atom_ndx]->setY( y + current_atom->getPosY() ); |
679 |
|
|
the_atoms[current_atom_ndx]->setZ( z + current_atom->getPosZ() ); |
680 |
chuckv |
124 |
|
681 |
mmeineke |
10 |
if( the_atoms[current_atom_ndx]->isDirectional() ){ |
682 |
chuckv |
124 |
|
683 |
mmeineke |
10 |
dAtom = (DirectionalAtom *)the_atoms[current_atom_ndx]; |
684 |
chuckv |
124 |
|
685 |
mmeineke |
10 |
rotMat[0][0] = 1.0; |
686 |
|
|
rotMat[0][1] = 0.0; |
687 |
|
|
rotMat[0][2] = 0.0; |
688 |
|
|
|
689 |
|
|
rotMat[1][0] = 0.0; |
690 |
|
|
rotMat[1][1] = 1.0; |
691 |
|
|
rotMat[1][2] = 0.0; |
692 |
|
|
|
693 |
|
|
rotMat[2][0] = 0.0; |
694 |
|
|
rotMat[2][1] = 0.0; |
695 |
|
|
rotMat[2][2] = 1.0; |
696 |
|
|
|
697 |
|
|
dAtom->setA( rotMat ); |
698 |
|
|
} |
699 |
|
|
|
700 |
|
|
current_atom_ndx++; |
701 |
|
|
} |
702 |
chuckv |
124 |
|
703 |
mmeineke |
10 |
current_mol++; |
704 |
|
|
current_comp_mol++; |
705 |
|
|
|
706 |
|
|
if( current_comp_mol >= components_nmol[current_comp] ){ |
707 |
chuckv |
124 |
|
708 |
mmeineke |
10 |
current_comp_mol = 0; |
709 |
|
|
current_comp++; |
710 |
|
|
} |
711 |
|
|
} |