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 |
176 |
#include "simError.h" |
10 |
mmeineke |
144 |
|
11 |
chuckv |
131 |
#ifdef IS_MPI |
12 |
chuckv |
139 |
#include "mpiBASS.h" |
13 |
chuckv |
215 |
#include "mpiSimulation.hpp" |
14 |
chuckv |
131 |
#include "bassDiag.hpp" |
15 |
|
|
#endif |
16 |
mmeineke |
10 |
|
17 |
|
|
SimSetup::SimSetup(){ |
18 |
|
|
stamps = new MakeStamps(); |
19 |
|
|
globals = new Globals(); |
20 |
mmeineke |
164 |
|
21 |
|
|
#ifdef IS_MPI |
22 |
|
|
strcpy( checkPointMsg, "SimSetup creation successful" ); |
23 |
|
|
MPIcheckPoint(); |
24 |
mmeineke |
176 |
#endif // IS_MPI |
25 |
mmeineke |
10 |
} |
26 |
|
|
|
27 |
|
|
SimSetup::~SimSetup(){ |
28 |
|
|
delete stamps; |
29 |
|
|
delete globals; |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
void SimSetup::parseFile( char* fileName ){ |
33 |
|
|
|
34 |
chuckv |
131 |
#ifdef IS_MPI |
35 |
mmeineke |
164 |
if( worldRank == 0 ){ |
36 |
|
|
#endif // is_mpi |
37 |
|
|
|
38 |
|
|
inFileName = fileName; |
39 |
|
|
set_interface_stamps( stamps, globals ); |
40 |
|
|
|
41 |
|
|
#ifdef IS_MPI |
42 |
|
|
mpiEventInit(); |
43 |
chuckv |
124 |
#endif |
44 |
mmeineke |
164 |
|
45 |
|
|
yacc_BASS( fileName ); |
46 |
|
|
|
47 |
chuckv |
131 |
#ifdef IS_MPI |
48 |
mmeineke |
164 |
throwMPIEvent(NULL); |
49 |
|
|
} |
50 |
mmeineke |
176 |
else receiveParse(); |
51 |
chuckv |
124 |
#endif |
52 |
|
|
|
53 |
mmeineke |
10 |
} |
54 |
|
|
|
55 |
chuckv |
131 |
#ifdef IS_MPI |
56 |
chuckv |
124 |
void SimSetup::receiveParse(void){ |
57 |
|
|
|
58 |
|
|
set_interface_stamps( stamps, globals ); |
59 |
|
|
mpiEventInit(); |
60 |
mmeineke |
164 |
MPIcheckPoint(); |
61 |
chuckv |
124 |
mpiEventLoop(); |
62 |
|
|
|
63 |
|
|
} |
64 |
|
|
|
65 |
chuckv |
131 |
|
66 |
chuckv |
128 |
void SimSetup::testMe(void){ |
67 |
|
|
bassDiag* dumpMe = new bassDiag(globals,stamps); |
68 |
|
|
dumpMe->dumpStamps(); |
69 |
|
|
delete dumpMe; |
70 |
|
|
} |
71 |
chuckv |
131 |
#endif |
72 |
mmeineke |
176 |
|
73 |
mmeineke |
10 |
void SimSetup::createSim( void ){ |
74 |
|
|
|
75 |
|
|
MakeStamps *the_stamps; |
76 |
|
|
Globals* the_globals; |
77 |
mmeineke |
202 |
int i, j; |
78 |
mmeineke |
10 |
|
79 |
|
|
// get the stamps and globals; |
80 |
|
|
the_stamps = stamps; |
81 |
|
|
the_globals = globals; |
82 |
|
|
|
83 |
|
|
// set the easy ones first |
84 |
|
|
simnfo->target_temp = the_globals->getTargetTemp(); |
85 |
|
|
simnfo->dt = the_globals->getDt(); |
86 |
|
|
simnfo->run_time = the_globals->getRunTime(); |
87 |
|
|
|
88 |
|
|
// get the ones we know are there, yet still may need some work. |
89 |
|
|
n_components = the_globals->getNComponents(); |
90 |
|
|
strcpy( force_field, the_globals->getForceField() ); |
91 |
|
|
strcpy( ensemble, the_globals->getEnsemble() ); |
92 |
chuckv |
124 |
|
93 |
mmeineke |
10 |
if( !strcmp( force_field, "TraPPE" ) ) the_ff = new TraPPEFF(); |
94 |
|
|
else if( !strcmp( force_field, "DipoleTest" ) ) the_ff = new DipoleTestFF(); |
95 |
|
|
else if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF(); |
96 |
chuckv |
215 |
else if( !strcmp( force_field, "LJ" ) ) the_ff = new LJ_FF(); |
97 |
mmeineke |
10 |
else{ |
98 |
mmeineke |
176 |
sprintf( painCave.errMsg, |
99 |
|
|
"SimSetup Error. Unrecognized force field -> %s\n", |
100 |
|
|
force_field ); |
101 |
|
|
painCave.isFatal = 1; |
102 |
|
|
simError(); |
103 |
mmeineke |
10 |
} |
104 |
|
|
|
105 |
mmeineke |
176 |
#ifdef IS_MPI |
106 |
|
|
strcpy( checkPointMsg, "ForceField creation successful" ); |
107 |
|
|
MPIcheckPoint(); |
108 |
|
|
#endif // is_mpi |
109 |
|
|
|
110 |
mmeineke |
10 |
// get the components and calculate the tot_nMol and indvidual n_mol |
111 |
|
|
the_components = the_globals->getComponents(); |
112 |
|
|
components_nmol = new int[n_components]; |
113 |
|
|
comp_stamps = new MoleculeStamp*[n_components]; |
114 |
chuckv |
124 |
|
115 |
mmeineke |
10 |
if( !the_globals->haveNMol() ){ |
116 |
chuckv |
124 |
// we don't have the total number of molecules, so we assume it is |
117 |
mmeineke |
10 |
// given in each component |
118 |
|
|
|
119 |
|
|
tot_nmol = 0; |
120 |
|
|
for( i=0; i<n_components; i++ ){ |
121 |
chuckv |
124 |
|
122 |
mmeineke |
10 |
if( !the_components[i]->haveNMol() ){ |
123 |
|
|
// we have a problem |
124 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
125 |
|
|
"SimSetup Error. No global NMol or component NMol" |
126 |
|
|
" given. Cannot calculate the number of atoms.\n" ); |
127 |
|
|
painCave.isFatal = 1; |
128 |
|
|
simError(); |
129 |
mmeineke |
10 |
} |
130 |
|
|
|
131 |
|
|
tot_nmol += the_components[i]->getNMol(); |
132 |
|
|
components_nmol[i] = the_components[i]->getNMol(); |
133 |
|
|
} |
134 |
|
|
} |
135 |
|
|
else{ |
136 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
137 |
|
|
"SimSetup error.\n" |
138 |
|
|
"\tSorry, the ability to specify total" |
139 |
|
|
" nMols and then give molfractions in the components\n" |
140 |
|
|
"\tis not currently supported." |
141 |
|
|
" Please give nMol in the components.\n" ); |
142 |
|
|
painCave.isFatal = 1; |
143 |
|
|
simError(); |
144 |
|
|
|
145 |
|
|
|
146 |
|
|
// tot_nmol = the_globals->getNMol(); |
147 |
|
|
|
148 |
|
|
// //we have the total number of molecules, now we check for molfractions |
149 |
|
|
// for( i=0; i<n_components; i++ ){ |
150 |
|
|
|
151 |
|
|
// if( !the_components[i]->haveMolFraction() ){ |
152 |
|
|
|
153 |
|
|
// if( !the_components[i]->haveNMol() ){ |
154 |
|
|
// //we have a problem |
155 |
|
|
// std::cerr << "SimSetup error. Neither molFraction nor " |
156 |
|
|
// << " nMol was given in component |
157 |
|
|
|
158 |
|
|
} |
159 |
chuckv |
124 |
|
160 |
mmeineke |
189 |
#ifdef IS_MPI |
161 |
|
|
strcpy( checkPointMsg, "Have the number of components" ); |
162 |
|
|
MPIcheckPoint(); |
163 |
|
|
#endif // is_mpi |
164 |
chuckv |
124 |
|
165 |
mmeineke |
10 |
// make an array of molecule stamps that match the components used. |
166 |
mmeineke |
198 |
// also extract the used stamps out into a separate linked list |
167 |
mmeineke |
10 |
|
168 |
mmeineke |
198 |
simnfo->nComponents = n_components; |
169 |
|
|
simnfo->componentsNmol = components_nmol; |
170 |
|
|
simnfo->compStamps = comp_stamps; |
171 |
|
|
simnfo->headStamp = new LinkedMolStamp(); |
172 |
|
|
|
173 |
|
|
char* id; |
174 |
|
|
LinkedMolStamp* headStamp = simnfo->headStamp; |
175 |
|
|
LinkedMolStamp* currentStamp = NULL; |
176 |
mmeineke |
10 |
for( i=0; i<n_components; i++ ){ |
177 |
|
|
|
178 |
mmeineke |
198 |
id = the_components[i]->getType(); |
179 |
|
|
comp_stamps[i] = NULL; |
180 |
|
|
|
181 |
|
|
// check to make sure the component isn't already in the list |
182 |
|
|
|
183 |
|
|
comp_stamps[i] = headStamp->match( id ); |
184 |
|
|
if( comp_stamps[i] == NULL ){ |
185 |
|
|
|
186 |
|
|
// extract the component from the list; |
187 |
|
|
|
188 |
|
|
currentStamp = the_stamps->extractMolStamp( id ); |
189 |
|
|
if( currentStamp == NULL ){ |
190 |
|
|
sprintf( painCave.errMsg, |
191 |
|
|
"SimSetup error: Component \"%s\" was not found in the " |
192 |
chuckv |
249 |
"list of declared molecules\n", |
193 |
mmeineke |
198 |
id ); |
194 |
|
|
painCave.isFatal = 1; |
195 |
|
|
simError(); |
196 |
|
|
} |
197 |
|
|
|
198 |
|
|
headStamp->add( currentStamp ); |
199 |
|
|
comp_stamps[i] = headStamp->match( id ); |
200 |
|
|
} |
201 |
mmeineke |
10 |
} |
202 |
|
|
|
203 |
mmeineke |
198 |
#ifdef IS_MPI |
204 |
|
|
strcpy( checkPointMsg, "Component stamps successfully extracted\n" ); |
205 |
|
|
MPIcheckPoint(); |
206 |
|
|
#endif // is_mpi |
207 |
|
|
|
208 |
mmeineke |
10 |
|
209 |
chuckv |
124 |
|
210 |
mmeineke |
198 |
|
211 |
mmeineke |
10 |
// caclulate the number of atoms, bonds, bends and torsions |
212 |
|
|
|
213 |
|
|
tot_atoms = 0; |
214 |
|
|
tot_bonds = 0; |
215 |
|
|
tot_bends = 0; |
216 |
|
|
tot_torsions = 0; |
217 |
|
|
for( i=0; i<n_components; i++ ){ |
218 |
mmeineke |
202 |
|
219 |
|
|
tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
220 |
|
|
tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
221 |
|
|
tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
222 |
mmeineke |
10 |
tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); |
223 |
|
|
} |
224 |
chuckv |
124 |
|
225 |
mmeineke |
10 |
tot_SRI = tot_bonds + tot_bends + tot_torsions; |
226 |
chuckv |
124 |
|
227 |
mmeineke |
10 |
simnfo->n_atoms = tot_atoms; |
228 |
|
|
simnfo->n_bonds = tot_bonds; |
229 |
|
|
simnfo->n_bends = tot_bends; |
230 |
|
|
simnfo->n_torsions = tot_torsions; |
231 |
|
|
simnfo->n_SRI = tot_SRI; |
232 |
chuckv |
195 |
simnfo->n_mol = tot_nmol; |
233 |
mmeineke |
10 |
|
234 |
chuckv |
195 |
|
235 |
|
|
#ifdef IS_MPI |
236 |
|
|
|
237 |
chuckv |
194 |
// divide the molecules among processors here. |
238 |
chuckv |
195 |
|
239 |
chuckv |
215 |
mpiSim = new mpiSimulation( simnfo ); |
240 |
chuckv |
195 |
|
241 |
mmeineke |
202 |
mpiSim->divideLabor(); |
242 |
chuckv |
194 |
|
243 |
mmeineke |
202 |
// set up the local variables |
244 |
|
|
|
245 |
mmeineke |
205 |
int localMol, allMol; |
246 |
mmeineke |
202 |
int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; |
247 |
|
|
|
248 |
mmeineke |
205 |
allMol = 0; |
249 |
mmeineke |
202 |
localMol = 0; |
250 |
|
|
local_atoms = 0; |
251 |
|
|
local_bonds = 0; |
252 |
|
|
local_bends = 0; |
253 |
|
|
local_torsions = 0; |
254 |
|
|
for( i=0; i<n_components; i++ ){ |
255 |
|
|
|
256 |
|
|
for( j=0; j<components_nmol[i]; j++ ){ |
257 |
|
|
|
258 |
mmeineke |
205 |
if( mpiSim->getMyMolStart() <= allMol && |
259 |
|
|
allMol <= mpiSim->getMyMolEnd() ){ |
260 |
mmeineke |
202 |
|
261 |
|
|
local_atoms += comp_stamps[i]->getNAtoms(); |
262 |
|
|
local_bonds += comp_stamps[i]->getNBonds(); |
263 |
|
|
local_bends += comp_stamps[i]->getNBends(); |
264 |
|
|
local_torsions += comp_stamps[i]->getNTorsions(); |
265 |
|
|
localMol++; |
266 |
|
|
} |
267 |
mmeineke |
205 |
allMol++; |
268 |
mmeineke |
202 |
} |
269 |
|
|
} |
270 |
mmeineke |
205 |
local_SRI = local_bonds + local_bends + local_torsions; |
271 |
mmeineke |
202 |
|
272 |
|
|
|
273 |
|
|
simnfo->n_atoms = mpiSim->getMyNlocal(); |
274 |
|
|
|
275 |
mmeineke |
205 |
if( local_atoms != simnfo->n_atoms ){ |
276 |
|
|
sprintf( painCave.errMsg, |
277 |
|
|
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's" |
278 |
|
|
" localAtom (%d) are note equal.\n", |
279 |
|
|
simnfo->n_atoms, |
280 |
|
|
local_atoms ); |
281 |
|
|
painCave.isFatal = 1; |
282 |
|
|
simError(); |
283 |
|
|
} |
284 |
mmeineke |
202 |
|
285 |
mmeineke |
205 |
simnfo->n_bonds = local_bonds; |
286 |
|
|
simnfo->n_bends = local_bends; |
287 |
|
|
simnfo->n_torsions = local_torsions; |
288 |
|
|
simnfo->n_SRI = local_SRI; |
289 |
|
|
simnfo->n_mol = localMol; |
290 |
|
|
|
291 |
|
|
strcpy( checkPointMsg, "Passed nlocal consistency check." ); |
292 |
|
|
MPIcheckPoint(); |
293 |
|
|
|
294 |
|
|
|
295 |
chuckv |
195 |
#endif // is_mpi |
296 |
|
|
|
297 |
chuckv |
194 |
|
298 |
mmeineke |
10 |
// create the atom and short range interaction arrays |
299 |
chuckv |
124 |
|
300 |
chuckv |
195 |
Atom::createArrays(simnfo->n_atoms); |
301 |
|
|
the_atoms = new Atom*[simnfo->n_atoms]; |
302 |
|
|
the_molecules = new Molecule[simnfo->n_mol]; |
303 |
chuckv |
124 |
|
304 |
|
|
|
305 |
chuckv |
195 |
if( simnfo->n_SRI ){ |
306 |
|
|
the_sris = new SRI*[simnfo->n_SRI]; |
307 |
|
|
the_excludes = new ex_pair[simnfo->n_SRI]; |
308 |
mmeineke |
10 |
} |
309 |
|
|
|
310 |
|
|
// set the arrays into the SimInfo object |
311 |
|
|
|
312 |
|
|
simnfo->atoms = the_atoms; |
313 |
|
|
simnfo->sr_interactions = the_sris; |
314 |
|
|
simnfo->n_exclude = tot_SRI; |
315 |
|
|
simnfo->excludes = the_excludes; |
316 |
|
|
|
317 |
chuckv |
124 |
|
318 |
mmeineke |
10 |
// get some of the tricky things that may still be in the globals |
319 |
|
|
|
320 |
|
|
if( simnfo->n_dipoles ){ |
321 |
|
|
|
322 |
|
|
if( !the_globals->haveRRF() ){ |
323 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
324 |
|
|
"SimSetup Error, system has dipoles, but no rRF was set.\n"); |
325 |
|
|
painCave.isFatal = 1; |
326 |
|
|
simError(); |
327 |
mmeineke |
10 |
} |
328 |
|
|
if( !the_globals->haveDielectric() ){ |
329 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
330 |
|
|
"SimSetup Error, system has dipoles, but no" |
331 |
|
|
" dielectric was set.\n" ); |
332 |
|
|
painCave.isFatal = 1; |
333 |
|
|
simError(); |
334 |
mmeineke |
10 |
} |
335 |
|
|
|
336 |
|
|
simnfo->rRF = the_globals->getRRF(); |
337 |
|
|
simnfo->dielectric = the_globals->getDielectric(); |
338 |
|
|
} |
339 |
|
|
|
340 |
mmeineke |
189 |
#ifdef IS_MPI |
341 |
|
|
strcpy( checkPointMsg, "rRf and dielectric check out" ); |
342 |
|
|
MPIcheckPoint(); |
343 |
|
|
#endif // is_mpi |
344 |
|
|
|
345 |
mmeineke |
10 |
if( the_globals->haveBox() ){ |
346 |
|
|
simnfo->box_x = the_globals->getBox(); |
347 |
|
|
simnfo->box_y = the_globals->getBox(); |
348 |
|
|
simnfo->box_z = the_globals->getBox(); |
349 |
|
|
} |
350 |
|
|
else if( the_globals->haveDensity() ){ |
351 |
chuckv |
124 |
|
352 |
mmeineke |
10 |
double vol; |
353 |
|
|
vol = (double)tot_nmol / the_globals->getDensity(); |
354 |
|
|
simnfo->box_x = pow( vol, ( 1.0 / 3.0 ) ); |
355 |
|
|
simnfo->box_y = simnfo->box_x; |
356 |
|
|
simnfo->box_z = simnfo->box_x; |
357 |
|
|
} |
358 |
|
|
else{ |
359 |
|
|
if( !the_globals->haveBoxX() ){ |
360 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
361 |
|
|
"SimSetup error, no periodic BoxX size given.\n" ); |
362 |
|
|
painCave.isFatal = 1; |
363 |
|
|
simError(); |
364 |
mmeineke |
10 |
} |
365 |
|
|
simnfo->box_x = the_globals->getBoxX(); |
366 |
|
|
|
367 |
|
|
if( !the_globals->haveBoxY() ){ |
368 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
369 |
|
|
"SimSetup error, no periodic BoxY size given.\n" ); |
370 |
|
|
painCave.isFatal = 1; |
371 |
|
|
simError(); |
372 |
mmeineke |
10 |
} |
373 |
|
|
simnfo->box_y = the_globals->getBoxY(); |
374 |
|
|
|
375 |
|
|
if( !the_globals->haveBoxZ() ){ |
376 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
377 |
|
|
"SimSetup error, no periodic BoxZ size given.\n" ); |
378 |
|
|
painCave.isFatal = 1; |
379 |
|
|
simError(); |
380 |
mmeineke |
10 |
} |
381 |
|
|
simnfo->box_z = the_globals->getBoxZ(); |
382 |
|
|
} |
383 |
|
|
|
384 |
mmeineke |
189 |
#ifdef IS_MPI |
385 |
|
|
strcpy( checkPointMsg, "Box size set up" ); |
386 |
|
|
MPIcheckPoint(); |
387 |
|
|
#endif // is_mpi |
388 |
chuckv |
124 |
|
389 |
mmeineke |
189 |
|
390 |
chuckv |
248 |
// initialize the arrays |
391 |
mmeineke |
189 |
|
392 |
chuckv |
248 |
the_ff->setSimInfo( simnfo ); |
393 |
|
|
|
394 |
|
|
makeAtoms(); |
395 |
|
|
|
396 |
|
|
if( tot_bonds ){ |
397 |
|
|
makeBonds(); |
398 |
|
|
} |
399 |
|
|
|
400 |
|
|
if( tot_bends ){ |
401 |
|
|
makeBends(); |
402 |
|
|
} |
403 |
|
|
|
404 |
|
|
if( tot_torsions ){ |
405 |
|
|
makeTorsions(); |
406 |
|
|
} |
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
|
413 |
chuckv |
206 |
if( the_globals->haveInitialConfig() ){ |
414 |
|
|
|
415 |
|
|
InitializeFromFile* fileInit; |
416 |
|
|
#ifdef IS_MPI // is_mpi |
417 |
|
|
if( worldRank == 0 ){ |
418 |
|
|
#endif //is_mpi |
419 |
|
|
fileInit = new InitializeFromFile( the_globals->getInitialConfig() ); |
420 |
|
|
#ifdef IS_MPI |
421 |
|
|
}else fileInit = new InitializeFromFile( NULL ); |
422 |
|
|
#endif |
423 |
|
|
fileInit->read_xyz( simnfo ); // default velocities on |
424 |
chuckv |
124 |
|
425 |
chuckv |
206 |
delete fileInit; |
426 |
|
|
} |
427 |
|
|
else{ |
428 |
chuckv |
124 |
|
429 |
chuckv |
195 |
#ifdef IS_MPI |
430 |
|
|
|
431 |
|
|
// no init from bass |
432 |
|
|
|
433 |
|
|
sprintf( painCave.errMsg, |
434 |
|
|
"Cannot intialize a parallel simulation without an initial configuration file.\n" ); |
435 |
|
|
painCave.isFatal; |
436 |
|
|
simError(); |
437 |
|
|
|
438 |
|
|
#else |
439 |
|
|
|
440 |
mmeineke |
189 |
initFromBass(); |
441 |
chuckv |
195 |
|
442 |
chuckv |
206 |
|
443 |
|
|
#endif |
444 |
|
|
} |
445 |
|
|
|
446 |
mmeineke |
189 |
#ifdef IS_MPI |
447 |
chuckv |
195 |
strcpy( checkPointMsg, "Successfully read in the initial configuration" ); |
448 |
mmeineke |
189 |
MPIcheckPoint(); |
449 |
|
|
#endif // is_mpi |
450 |
mmeineke |
10 |
|
451 |
|
|
|
452 |
mmeineke |
189 |
|
453 |
|
|
|
454 |
|
|
|
455 |
chuckv |
206 |
|
456 |
mmeineke |
189 |
|
457 |
mmeineke |
184 |
#ifdef IS_MPI |
458 |
mmeineke |
189 |
if( worldRank == 0 ){ |
459 |
mmeineke |
184 |
#endif // is_mpi |
460 |
mmeineke |
189 |
|
461 |
|
|
if( the_globals->haveFinalConfig() ){ |
462 |
|
|
strcpy( simnfo->finalName, the_globals->getFinalConfig() ); |
463 |
|
|
} |
464 |
|
|
else{ |
465 |
|
|
strcpy( simnfo->finalName, inFileName ); |
466 |
|
|
char* endTest; |
467 |
|
|
int nameLength = strlen( simnfo->finalName ); |
468 |
|
|
endTest = &(simnfo->finalName[nameLength - 5]); |
469 |
|
|
if( !strcmp( endTest, ".bass" ) ){ |
470 |
|
|
strcpy( endTest, ".eor" ); |
471 |
mmeineke |
184 |
} |
472 |
mmeineke |
189 |
else if( !strcmp( endTest, ".BASS" ) ){ |
473 |
|
|
strcpy( endTest, ".eor" ); |
474 |
|
|
} |
475 |
mmeineke |
184 |
else{ |
476 |
mmeineke |
189 |
endTest = &(simnfo->finalName[nameLength - 4]); |
477 |
|
|
if( !strcmp( endTest, ".bss" ) ){ |
478 |
mmeineke |
184 |
strcpy( endTest, ".eor" ); |
479 |
|
|
} |
480 |
mmeineke |
189 |
else if( !strcmp( endTest, ".mdl" ) ){ |
481 |
mmeineke |
184 |
strcpy( endTest, ".eor" ); |
482 |
|
|
} |
483 |
|
|
else{ |
484 |
mmeineke |
189 |
strcat( simnfo->finalName, ".eor" ); |
485 |
mmeineke |
184 |
} |
486 |
|
|
} |
487 |
mmeineke |
189 |
} |
488 |
|
|
|
489 |
|
|
// make the sample and status out names |
490 |
|
|
|
491 |
|
|
strcpy( simnfo->sampleName, inFileName ); |
492 |
|
|
char* endTest; |
493 |
|
|
int nameLength = strlen( simnfo->sampleName ); |
494 |
|
|
endTest = &(simnfo->sampleName[nameLength - 5]); |
495 |
|
|
if( !strcmp( endTest, ".bass" ) ){ |
496 |
|
|
strcpy( endTest, ".dump" ); |
497 |
|
|
} |
498 |
|
|
else if( !strcmp( endTest, ".BASS" ) ){ |
499 |
|
|
strcpy( endTest, ".dump" ); |
500 |
|
|
} |
501 |
|
|
else{ |
502 |
|
|
endTest = &(simnfo->sampleName[nameLength - 4]); |
503 |
|
|
if( !strcmp( endTest, ".bss" ) ){ |
504 |
mmeineke |
184 |
strcpy( endTest, ".dump" ); |
505 |
|
|
} |
506 |
mmeineke |
189 |
else if( !strcmp( endTest, ".mdl" ) ){ |
507 |
mmeineke |
184 |
strcpy( endTest, ".dump" ); |
508 |
|
|
} |
509 |
|
|
else{ |
510 |
mmeineke |
189 |
strcat( simnfo->sampleName, ".dump" ); |
511 |
mmeineke |
184 |
} |
512 |
mmeineke |
189 |
} |
513 |
|
|
|
514 |
|
|
strcpy( simnfo->statusName, inFileName ); |
515 |
|
|
nameLength = strlen( simnfo->statusName ); |
516 |
|
|
endTest = &(simnfo->statusName[nameLength - 5]); |
517 |
|
|
if( !strcmp( endTest, ".bass" ) ){ |
518 |
|
|
strcpy( endTest, ".stat" ); |
519 |
|
|
} |
520 |
|
|
else if( !strcmp( endTest, ".BASS" ) ){ |
521 |
|
|
strcpy( endTest, ".stat" ); |
522 |
|
|
} |
523 |
|
|
else{ |
524 |
|
|
endTest = &(simnfo->statusName[nameLength - 4]); |
525 |
|
|
if( !strcmp( endTest, ".bss" ) ){ |
526 |
mmeineke |
184 |
strcpy( endTest, ".stat" ); |
527 |
|
|
} |
528 |
mmeineke |
189 |
else if( !strcmp( endTest, ".mdl" ) ){ |
529 |
mmeineke |
184 |
strcpy( endTest, ".stat" ); |
530 |
|
|
} |
531 |
|
|
else{ |
532 |
mmeineke |
189 |
strcat( simnfo->statusName, ".stat" ); |
533 |
mmeineke |
184 |
} |
534 |
mmeineke |
189 |
} |
535 |
|
|
|
536 |
mmeineke |
184 |
#ifdef IS_MPI |
537 |
mmeineke |
189 |
} |
538 |
mmeineke |
184 |
#endif // is_mpi |
539 |
mmeineke |
189 |
|
540 |
mmeineke |
10 |
// set the status, sample, and themal kick times |
541 |
mmeineke |
189 |
|
542 |
mmeineke |
10 |
if( the_globals->haveSampleTime() ){ |
543 |
chuckv |
124 |
simnfo->sampleTime = the_globals->getSampleTime(); |
544 |
mmeineke |
10 |
simnfo->statusTime = simnfo->sampleTime; |
545 |
|
|
simnfo->thermalTime = simnfo->sampleTime; |
546 |
|
|
} |
547 |
|
|
else{ |
548 |
chuckv |
124 |
simnfo->sampleTime = the_globals->getRunTime(); |
549 |
mmeineke |
10 |
simnfo->statusTime = simnfo->sampleTime; |
550 |
|
|
simnfo->thermalTime = simnfo->sampleTime; |
551 |
|
|
} |
552 |
|
|
|
553 |
|
|
if( the_globals->haveStatusTime() ){ |
554 |
|
|
simnfo->statusTime = the_globals->getStatusTime(); |
555 |
|
|
} |
556 |
|
|
|
557 |
|
|
if( the_globals->haveThermalTime() ){ |
558 |
|
|
simnfo->thermalTime = the_globals->getThermalTime(); |
559 |
|
|
} |
560 |
|
|
|
561 |
|
|
// check for the temperature set flag |
562 |
|
|
|
563 |
|
|
if( the_globals->haveTempSet() ) simnfo->setTemp = the_globals->getTempSet(); |
564 |
chuckv |
124 |
|
565 |
|
|
|
566 |
chuckv |
248 |
// // make the longe range forces and the integrator |
567 |
chuckv |
124 |
|
568 |
chuckv |
248 |
// new AllLong( simnfo ); |
569 |
chuckv |
124 |
|
570 |
chuckv |
249 |
if( !strcmp( force_field, "TraPPE" ) ) new Verlet( *simnfo, the_ff ); |
571 |
mmeineke |
10 |
if( !strcmp( force_field, "DipoleTest" ) ) new Symplectic( simnfo ); |
572 |
|
|
if( !strcmp( force_field, "TraPPE_Ex" ) ) new Symplectic( simnfo ); |
573 |
chuckv |
248 |
if( !strcmp( force_field, "LJ" ) ) new Verlet( *simnfo, the_ff ); |
574 |
|
|
|
575 |
mmeineke |
10 |
} |
576 |
|
|
|
577 |
|
|
void SimSetup::makeAtoms( void ){ |
578 |
chuckv |
124 |
|
579 |
mmeineke |
10 |
int i, j, k, index; |
580 |
|
|
double ux, uy, uz, uSqr, u; |
581 |
|
|
AtomStamp* current_atom; |
582 |
|
|
DirectionalAtom* dAtom; |
583 |
mmeineke |
205 |
int molIndex, molStart, molEnd, nMemb, lMolIndex; |
584 |
mmeineke |
10 |
|
585 |
mmeineke |
205 |
lMolIndex = 0; |
586 |
mmeineke |
117 |
molIndex = 0; |
587 |
mmeineke |
10 |
index = 0; |
588 |
|
|
for( i=0; i<n_components; i++ ){ |
589 |
chuckv |
124 |
|
590 |
mmeineke |
10 |
for( j=0; j<components_nmol[i]; j++ ){ |
591 |
chuckv |
124 |
|
592 |
mmeineke |
205 |
#ifdef IS_MPI |
593 |
chuckv |
215 |
if( mpiSim->getMyMolStart() <= molIndex && |
594 |
|
|
molIndex <= mpiSim->getMyMolEnd() ){ |
595 |
mmeineke |
205 |
#endif // is_mpi |
596 |
chuckv |
124 |
|
597 |
mmeineke |
205 |
molStart = index; |
598 |
|
|
nMemb = comp_stamps[i]->getNAtoms(); |
599 |
|
|
for( k=0; k<comp_stamps[i]->getNAtoms(); k++ ){ |
600 |
|
|
|
601 |
|
|
current_atom = comp_stamps[i]->getAtom( k ); |
602 |
|
|
if( current_atom->haveOrientation() ){ |
603 |
|
|
|
604 |
|
|
dAtom = new DirectionalAtom(index); |
605 |
|
|
simnfo->n_oriented++; |
606 |
|
|
the_atoms[index] = dAtom; |
607 |
|
|
|
608 |
|
|
ux = current_atom->getOrntX(); |
609 |
|
|
uy = current_atom->getOrntY(); |
610 |
|
|
uz = current_atom->getOrntZ(); |
611 |
|
|
|
612 |
|
|
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
613 |
|
|
|
614 |
|
|
u = sqrt( uSqr ); |
615 |
|
|
ux = ux / u; |
616 |
|
|
uy = uy / u; |
617 |
|
|
uz = uz / u; |
618 |
|
|
|
619 |
|
|
dAtom->setSUx( ux ); |
620 |
|
|
dAtom->setSUy( uy ); |
621 |
|
|
dAtom->setSUz( uz ); |
622 |
|
|
} |
623 |
|
|
else{ |
624 |
|
|
the_atoms[index] = new GeneralAtom(index); |
625 |
|
|
} |
626 |
|
|
the_atoms[index]->setType( current_atom->getType() ); |
627 |
|
|
the_atoms[index]->setIndex( index ); |
628 |
|
|
|
629 |
|
|
// increment the index and repeat; |
630 |
|
|
index++; |
631 |
mmeineke |
10 |
} |
632 |
mmeineke |
205 |
|
633 |
|
|
molEnd = index -1; |
634 |
|
|
the_molecules[lMolIndex].setNMembers( nMemb ); |
635 |
|
|
the_molecules[lMolIndex].setStartAtom( molStart ); |
636 |
|
|
the_molecules[lMolIndex].setEndAtom( molEnd ); |
637 |
|
|
the_molecules[lMolIndex].setStampID( i ); |
638 |
|
|
lMolIndex++; |
639 |
chuckv |
124 |
|
640 |
mmeineke |
205 |
#ifdef IS_MPI |
641 |
mmeineke |
10 |
} |
642 |
mmeineke |
205 |
#endif //is_mpi |
643 |
|
|
|
644 |
mmeineke |
117 |
molIndex++; |
645 |
mmeineke |
10 |
} |
646 |
|
|
} |
647 |
chuckv |
124 |
|
648 |
mmeineke |
10 |
the_ff->initializeAtoms(); |
649 |
|
|
} |
650 |
|
|
|
651 |
|
|
void SimSetup::makeBonds( void ){ |
652 |
|
|
|
653 |
mmeineke |
205 |
int i, j, k, index, offset, molIndex; |
654 |
mmeineke |
10 |
bond_pair* the_bonds; |
655 |
|
|
BondStamp* current_bond; |
656 |
|
|
|
657 |
|
|
the_bonds = new bond_pair[tot_bonds]; |
658 |
|
|
index = 0; |
659 |
|
|
offset = 0; |
660 |
chuckv |
249 |
molIndex = 0; |
661 |
chuckv |
215 |
|
662 |
mmeineke |
10 |
for( i=0; i<n_components; i++ ){ |
663 |
chuckv |
124 |
|
664 |
mmeineke |
10 |
for( j=0; j<components_nmol[i]; j++ ){ |
665 |
chuckv |
124 |
|
666 |
mmeineke |
205 |
#ifdef IS_MPI |
667 |
chuckv |
215 |
if( mpiSim->getMyMolStart() <= molIndex && |
668 |
|
|
molIndex <= mpiSim->getMyMolEnd() ){ |
669 |
mmeineke |
205 |
#endif // is_mpi |
670 |
|
|
|
671 |
|
|
for( k=0; k<comp_stamps[i]->getNBonds(); k++ ){ |
672 |
|
|
|
673 |
|
|
current_bond = comp_stamps[i]->getBond( k ); |
674 |
|
|
the_bonds[index].a = current_bond->getA() + offset; |
675 |
|
|
the_bonds[index].b = current_bond->getB() + offset; |
676 |
|
|
|
677 |
|
|
the_excludes[index].i = the_bonds[index].a; |
678 |
|
|
the_excludes[index].j = the_bonds[index].b; |
679 |
|
|
|
680 |
|
|
// increment the index and repeat; |
681 |
|
|
index++; |
682 |
|
|
} |
683 |
|
|
offset += comp_stamps[i]->getNAtoms(); |
684 |
|
|
|
685 |
|
|
#ifdef IS_MPI |
686 |
mmeineke |
10 |
} |
687 |
mmeineke |
205 |
#endif is_mpi |
688 |
|
|
|
689 |
|
|
molIndex++; |
690 |
|
|
} |
691 |
mmeineke |
10 |
} |
692 |
chuckv |
124 |
|
693 |
mmeineke |
10 |
the_ff->initializeBonds( the_bonds ); |
694 |
|
|
} |
695 |
|
|
|
696 |
|
|
void SimSetup::makeBends( void ){ |
697 |
|
|
|
698 |
mmeineke |
205 |
int i, j, k, index, offset, molIndex; |
699 |
mmeineke |
10 |
bend_set* the_bends; |
700 |
|
|
BendStamp* current_bend; |
701 |
|
|
|
702 |
|
|
the_bends = new bend_set[tot_bends]; |
703 |
|
|
index = 0; |
704 |
|
|
offset = 0; |
705 |
mmeineke |
205 |
molIndex = 0; |
706 |
mmeineke |
10 |
for( i=0; i<n_components; i++ ){ |
707 |
chuckv |
124 |
|
708 |
mmeineke |
10 |
for( j=0; j<components_nmol[i]; j++ ){ |
709 |
chuckv |
124 |
|
710 |
mmeineke |
205 |
#ifdef IS_MPI |
711 |
chuckv |
215 |
if( mpiSim->getMyMolStart() <= molIndex && |
712 |
|
|
molIndex <= mpiSim->getMyMolEnd() ){ |
713 |
mmeineke |
205 |
#endif // is_mpi |
714 |
chuckv |
124 |
|
715 |
mmeineke |
205 |
for( k=0; k<comp_stamps[i]->getNBends(); k++ ){ |
716 |
|
|
|
717 |
|
|
current_bend = comp_stamps[i]->getBend( k ); |
718 |
|
|
the_bends[index].a = current_bend->getA() + offset; |
719 |
|
|
the_bends[index].b = current_bend->getB() + offset; |
720 |
|
|
the_bends[index].c = current_bend->getC() + offset; |
721 |
|
|
|
722 |
|
|
the_excludes[index + tot_bonds].i = the_bends[index].a; |
723 |
|
|
the_excludes[index + tot_bonds].j = the_bends[index].c; |
724 |
|
|
|
725 |
|
|
// increment the index and repeat; |
726 |
|
|
index++; |
727 |
|
|
} |
728 |
|
|
offset += comp_stamps[i]->getNAtoms(); |
729 |
|
|
|
730 |
|
|
#ifdef IS_MPI |
731 |
|
|
} |
732 |
|
|
#endif //is_mpi |
733 |
mmeineke |
10 |
|
734 |
mmeineke |
205 |
molIndex++; |
735 |
mmeineke |
10 |
} |
736 |
|
|
} |
737 |
chuckv |
124 |
|
738 |
mmeineke |
10 |
the_ff->initializeBends( the_bends ); |
739 |
|
|
} |
740 |
|
|
|
741 |
|
|
void SimSetup::makeTorsions( void ){ |
742 |
|
|
|
743 |
mmeineke |
205 |
int i, j, k, index, offset, molIndex; |
744 |
mmeineke |
10 |
torsion_set* the_torsions; |
745 |
|
|
TorsionStamp* current_torsion; |
746 |
|
|
|
747 |
|
|
the_torsions = new torsion_set[tot_torsions]; |
748 |
|
|
index = 0; |
749 |
|
|
offset = 0; |
750 |
mmeineke |
205 |
molIndex = 0; |
751 |
mmeineke |
10 |
for( i=0; i<n_components; i++ ){ |
752 |
chuckv |
124 |
|
753 |
mmeineke |
10 |
for( j=0; j<components_nmol[i]; j++ ){ |
754 |
chuckv |
124 |
|
755 |
mmeineke |
205 |
#ifdef IS_MPI |
756 |
chuckv |
215 |
if( mpiSim->getMyMolStart() <= molIndex && |
757 |
|
|
molIndex <= mpiSim->getMyMolEnd() ){ |
758 |
mmeineke |
205 |
#endif // is_mpi |
759 |
|
|
|
760 |
mmeineke |
10 |
for( k=0; k<comp_stamps[i]->getNTorsions(); k++ ){ |
761 |
chuckv |
124 |
|
762 |
mmeineke |
10 |
current_torsion = comp_stamps[i]->getTorsion( k ); |
763 |
|
|
the_torsions[index].a = current_torsion->getA() + offset; |
764 |
|
|
the_torsions[index].b = current_torsion->getB() + offset; |
765 |
|
|
the_torsions[index].c = current_torsion->getC() + offset; |
766 |
|
|
the_torsions[index].d = current_torsion->getD() + offset; |
767 |
|
|
|
768 |
|
|
the_excludes[index + tot_bonds + tot_bends].i = the_torsions[index].a; |
769 |
|
|
the_excludes[index + tot_bonds + tot_bends].j = the_torsions[index].d; |
770 |
|
|
|
771 |
|
|
// increment the index and repeat; |
772 |
|
|
index++; |
773 |
|
|
} |
774 |
|
|
offset += comp_stamps[i]->getNAtoms(); |
775 |
mmeineke |
205 |
|
776 |
|
|
#ifdef IS_MPI |
777 |
|
|
} |
778 |
|
|
#endif //is_mpi |
779 |
|
|
|
780 |
|
|
molIndex++; |
781 |
mmeineke |
10 |
} |
782 |
|
|
} |
783 |
chuckv |
124 |
|
784 |
mmeineke |
10 |
the_ff->initializeTorsions( the_torsions ); |
785 |
|
|
} |
786 |
|
|
|
787 |
|
|
void SimSetup::initFromBass( void ){ |
788 |
|
|
|
789 |
|
|
int i, j, k; |
790 |
|
|
int n_cells; |
791 |
|
|
double cellx, celly, cellz; |
792 |
|
|
double temp1, temp2, temp3; |
793 |
|
|
int n_per_extra; |
794 |
|
|
int n_extra; |
795 |
|
|
int have_extra, done; |
796 |
|
|
|
797 |
|
|
temp1 = (double)tot_nmol / 4.0; |
798 |
|
|
temp2 = pow( temp1, ( 1.0 / 3.0 ) ); |
799 |
|
|
temp3 = ceil( temp2 ); |
800 |
|
|
|
801 |
|
|
have_extra =0; |
802 |
|
|
if( temp2 < temp3 ){ // we have a non-complete lattice |
803 |
|
|
have_extra =1; |
804 |
|
|
|
805 |
|
|
n_cells = (int)temp3 - 1; |
806 |
|
|
cellx = simnfo->box_x / temp3; |
807 |
|
|
celly = simnfo->box_y / temp3; |
808 |
|
|
cellz = simnfo->box_z / temp3; |
809 |
|
|
n_extra = tot_nmol - ( 4 * n_cells * n_cells * n_cells ); |
810 |
|
|
temp1 = ((double)n_extra) / ( pow( temp3, 3.0 ) - pow( n_cells, 3.0 ) ); |
811 |
|
|
n_per_extra = (int)ceil( temp1 ); |
812 |
|
|
|
813 |
|
|
if( n_per_extra > 4){ |
814 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
815 |
|
|
"SimSetup error. There has been an error in constructing" |
816 |
|
|
" the non-complete lattice.\n" ); |
817 |
|
|
painCave.isFatal = 1; |
818 |
|
|
simError(); |
819 |
mmeineke |
10 |
} |
820 |
|
|
} |
821 |
|
|
else{ |
822 |
|
|
n_cells = (int)temp3; |
823 |
|
|
cellx = simnfo->box_x / temp3; |
824 |
|
|
celly = simnfo->box_y / temp3; |
825 |
|
|
cellz = simnfo->box_z / temp3; |
826 |
|
|
} |
827 |
chuckv |
124 |
|
828 |
mmeineke |
10 |
current_mol = 0; |
829 |
|
|
current_comp_mol = 0; |
830 |
|
|
current_comp = 0; |
831 |
|
|
current_atom_ndx = 0; |
832 |
chuckv |
124 |
|
833 |
mmeineke |
10 |
for( i=0; i < n_cells ; i++ ){ |
834 |
|
|
for( j=0; j < n_cells; j++ ){ |
835 |
|
|
for( k=0; k < n_cells; k++ ){ |
836 |
chuckv |
124 |
|
837 |
mmeineke |
10 |
makeElement( i * cellx, |
838 |
|
|
j * celly, |
839 |
|
|
k * cellz ); |
840 |
chuckv |
124 |
|
841 |
mmeineke |
10 |
makeElement( i * cellx + 0.5 * cellx, |
842 |
|
|
j * celly + 0.5 * celly, |
843 |
|
|
k * cellz ); |
844 |
chuckv |
124 |
|
845 |
mmeineke |
10 |
makeElement( i * cellx, |
846 |
|
|
j * celly + 0.5 * celly, |
847 |
|
|
k * cellz + 0.5 * cellz ); |
848 |
chuckv |
124 |
|
849 |
mmeineke |
10 |
makeElement( i * cellx + 0.5 * cellx, |
850 |
|
|
j * celly, |
851 |
|
|
k * cellz + 0.5 * cellz ); |
852 |
|
|
} |
853 |
|
|
} |
854 |
|
|
} |
855 |
|
|
|
856 |
|
|
if( have_extra ){ |
857 |
|
|
done = 0; |
858 |
chuckv |
124 |
|
859 |
mmeineke |
10 |
int start_ndx; |
860 |
|
|
for( i=0; i < (n_cells+1) && !done; i++ ){ |
861 |
|
|
for( j=0; j < (n_cells+1) && !done; j++ ){ |
862 |
chuckv |
124 |
|
863 |
mmeineke |
10 |
if( i < n_cells ){ |
864 |
chuckv |
124 |
|
865 |
mmeineke |
10 |
if( j < n_cells ){ |
866 |
|
|
start_ndx = n_cells; |
867 |
|
|
} |
868 |
|
|
else start_ndx = 0; |
869 |
|
|
} |
870 |
|
|
else start_ndx = 0; |
871 |
chuckv |
124 |
|
872 |
mmeineke |
10 |
for( k=start_ndx; k < (n_cells+1) && !done; k++ ){ |
873 |
chuckv |
124 |
|
874 |
mmeineke |
10 |
makeElement( i * cellx, |
875 |
|
|
j * celly, |
876 |
|
|
k * cellz ); |
877 |
|
|
done = ( current_mol >= tot_nmol ); |
878 |
chuckv |
124 |
|
879 |
mmeineke |
10 |
if( !done && n_per_extra > 1 ){ |
880 |
|
|
makeElement( i * cellx + 0.5 * cellx, |
881 |
|
|
j * celly + 0.5 * celly, |
882 |
|
|
k * cellz ); |
883 |
|
|
done = ( current_mol >= tot_nmol ); |
884 |
|
|
} |
885 |
chuckv |
124 |
|
886 |
mmeineke |
10 |
if( !done && n_per_extra > 2){ |
887 |
|
|
makeElement( i * cellx, |
888 |
|
|
j * celly + 0.5 * celly, |
889 |
|
|
k * cellz + 0.5 * cellz ); |
890 |
|
|
done = ( current_mol >= tot_nmol ); |
891 |
|
|
} |
892 |
chuckv |
124 |
|
893 |
mmeineke |
10 |
if( !done && n_per_extra > 3){ |
894 |
|
|
makeElement( i * cellx + 0.5 * cellx, |
895 |
|
|
j * celly, |
896 |
|
|
k * cellz + 0.5 * cellz ); |
897 |
|
|
done = ( current_mol >= tot_nmol ); |
898 |
|
|
} |
899 |
|
|
} |
900 |
|
|
} |
901 |
|
|
} |
902 |
|
|
} |
903 |
chuckv |
124 |
|
904 |
|
|
|
905 |
mmeineke |
10 |
for( i=0; i<simnfo->n_atoms; i++ ){ |
906 |
|
|
simnfo->atoms[i]->set_vx( 0.0 ); |
907 |
|
|
simnfo->atoms[i]->set_vy( 0.0 ); |
908 |
|
|
simnfo->atoms[i]->set_vz( 0.0 ); |
909 |
|
|
} |
910 |
|
|
} |
911 |
|
|
|
912 |
|
|
void SimSetup::makeElement( double x, double y, double z ){ |
913 |
|
|
|
914 |
|
|
int k; |
915 |
|
|
AtomStamp* current_atom; |
916 |
|
|
DirectionalAtom* dAtom; |
917 |
|
|
double rotMat[3][3]; |
918 |
|
|
|
919 |
|
|
for( k=0; k<comp_stamps[current_comp]->getNAtoms(); k++ ){ |
920 |
chuckv |
124 |
|
921 |
mmeineke |
10 |
current_atom = comp_stamps[current_comp]->getAtom( k ); |
922 |
|
|
if( !current_atom->havePosition() ){ |
923 |
mmeineke |
189 |
sprintf( painCave.errMsg, |
924 |
|
|
"SimSetup:initFromBass error.\n" |
925 |
|
|
"\tComponent %s, atom %s does not have a position specified.\n" |
926 |
|
|
"\tThe initialization routine is unable to give a start" |
927 |
|
|
" position.\n", |
928 |
|
|
comp_stamps[current_comp]->getID(), |
929 |
|
|
current_atom->getType() ); |
930 |
|
|
painCave.isFatal = 1; |
931 |
|
|
simError(); |
932 |
mmeineke |
10 |
} |
933 |
chuckv |
124 |
|
934 |
mmeineke |
10 |
the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() ); |
935 |
|
|
the_atoms[current_atom_ndx]->setY( y + current_atom->getPosY() ); |
936 |
|
|
the_atoms[current_atom_ndx]->setZ( z + current_atom->getPosZ() ); |
937 |
chuckv |
124 |
|
938 |
mmeineke |
10 |
if( the_atoms[current_atom_ndx]->isDirectional() ){ |
939 |
chuckv |
124 |
|
940 |
mmeineke |
10 |
dAtom = (DirectionalAtom *)the_atoms[current_atom_ndx]; |
941 |
chuckv |
124 |
|
942 |
mmeineke |
10 |
rotMat[0][0] = 1.0; |
943 |
|
|
rotMat[0][1] = 0.0; |
944 |
|
|
rotMat[0][2] = 0.0; |
945 |
|
|
|
946 |
|
|
rotMat[1][0] = 0.0; |
947 |
|
|
rotMat[1][1] = 1.0; |
948 |
|
|
rotMat[1][2] = 0.0; |
949 |
|
|
|
950 |
|
|
rotMat[2][0] = 0.0; |
951 |
|
|
rotMat[2][1] = 0.0; |
952 |
|
|
rotMat[2][2] = 1.0; |
953 |
|
|
|
954 |
|
|
dAtom->setA( rotMat ); |
955 |
|
|
} |
956 |
|
|
|
957 |
|
|
current_atom_ndx++; |
958 |
|
|
} |
959 |
chuckv |
124 |
|
960 |
mmeineke |
10 |
current_mol++; |
961 |
|
|
current_comp_mol++; |
962 |
|
|
|
963 |
|
|
if( current_comp_mol >= components_nmol[current_comp] ){ |
964 |
chuckv |
124 |
|
965 |
mmeineke |
10 |
current_comp_mol = 0; |
966 |
|
|
current_comp++; |
967 |
|
|
} |
968 |
|
|
} |