ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/utils/sysbuilder/bilayerSys.cpp
(Generate patch)

Comparing trunk/OOPSE/utils/sysbuilder/bilayerSys.cpp (file contents):
Revision 678 by chuckv, Mon Aug 11 22:12:31 2003 UTC vs.
Revision 707 by mmeineke, Wed Aug 20 19:42:31 2003 UTC

# Line 1 | Line 1
1 +
2   #include <iostream>
3 + #include <vector>
4 + #include <algorithm>
5  
6   #include <cstdlib>
7   #include <cstring>
8   #include <cmath>
9  
10 +
11   #include "simError.h"
12   #include "SimInfo.hpp"
13   #include "ReadWrite.hpp"
# Line 12 | Line 16
16   #include "sysBuild.hpp"
17   #include "bilayerSys.hpp"
18  
19 + #include "latticeBuilder.hpp"
20  
21 + class SortCond{
22 +  
23 + public:
24 +  bool operator()(const pair<int, double>& p1, const pair<int, double>& p2){
25 +    return p1.second < p2.second;
26 +  }
27 +  
28 +  
29 + };
30  
31 +
32   void buildMap( double &x, double &y, double &z,
33 <          double boxX, double boxY, double boxZ );
33 >               double boxX, double boxY, double boxZ );
34  
35   int buildRandomBilayer( void );
36  
# Line 44 | Line 59 | int buildRandomBilayer( void ){
59    } coord;
60  
61  
62 +
63    const double waterRho = 0.0334; // number density per cubic angstrom
64    const double waterVol = 4.0 / waterRho; // volume occupied by 4 waters
65    const double waterCell = 4.929; // fcc unit cell length
66  
67 +  Lattice myFCC( FCC_LATTICE_TYPE, waterCell );
68 +  double *posX, *posY, *posZ;
69 +  double pos[3], posA[3], posB[3];
70 +
71    const double water_padding = 6.0;
72    const double lipid_spaceing = 8.0;
73  
74  
75 <  int i,j,k, l;
75 >  int i,j,k, l, m;
76    int nAtoms, atomIndex, molIndex, molID;
77    int* molSeq;
78    int* molMap;
# Line 67 | Line 87 | int buildRandomBilayer( void ){
87  
88    Atom** atoms;
89    SimInfo* simnfo;
90 +  SimState* theConfig;
91    DumpWriter* writer;
92  
93    MoleculeStamp* lipidStamp;
# Line 91 | Line 112 | int buildRandomBilayer( void ){
112    foundWater = 0;
113    for(i=0; i<bsInfo.nComponents; i++){
114      if( !strcmp( bsInfo.compStamps[i]->getID(), bsInfo.lipidName ) ){
115 <      
115 >          
116        foundLipid = 1;
117        lipidStamp = bsInfo.compStamps[i];
118        nLipids = bsInfo.componentsNmol[i];
119      }
120      if( !strcmp( bsInfo.compStamps[i]->getID(), bsInfo.waterName ) ){
121 <      
121 >          
122        foundWater = 1;
123 <      
123 >          
124        waterStamp = bsInfo.compStamps[i];
125        nWaters = bsInfo.componentsNmol[i];
126      }
# Line 112 | Line 133 | int buildRandomBilayer( void ){
133      simError();
134    }
135    if( !foundWater ){
136 <        sprintf(painCave.errMsg,
137 <                "Could not find solvent \"%s\" in the bass file.\n",
136 >    sprintf(painCave.errMsg,
137 >            "Could not find solvent \"%s\" in the bass file.\n",
138              bsInfo.waterName );
139      painCave.isFatal = 1;
140      simError();
# Line 128 | Line 149 | int buildRandomBilayer( void ){
149    waterLocate = new MoLocator( waterStamp );
150    waterNatoms = waterStamp->getNAtoms();
151    
152 <  nAtoms = nLipids * lipidNatoms;
152 >  nAtoms = lipidNatoms;
153  
154 < simnfo[0].n_atoms = nAtoms;
155 < simnfo[0].atoms=new Atom*[nAtoms];
154 >  simnfo[0].n_atoms = nAtoms;
155 >  simnfo[0].atoms=new Atom*[nAtoms];
156  
157 < (simnfo[0]->getConfiguration())->createArrays( simnfo[0].n_atoms );
158 < for(i=0; i<simnfo[0].n_atoms; i++) simnfo[0].atoms[i]->setCoords();
157 >  theConfig = simnfo[0].getConfiguration();
158 >  theConfig->createArrays( simnfo[0].n_atoms );
159  
160 < atoms=simnfo[0].atoms;
160 >  atoms=simnfo[0].atoms;
161          
162  
163    // create the test box for initial water displacement
# Line 160 | Line 181 | int buildRandomBilayer( void ){
181    for( i=0; i < nCells; i++ ){
182      for( j=0; j < nCells; j++ ){
183        for( k=0; k < nCells; k++ ){
184 <        
185 <        waterX[ndx] = i * waterCell + x0;
186 <        waterY[ndx] = j * waterCell + y0;
187 <        waterZ[ndx] = k * waterCell + z0;
188 <        ndx++;
189 <        
190 <        waterX[ndx] = i * waterCell + 0.5 * waterCell + x0;
191 <        waterY[ndx] = j * waterCell + 0.5 * waterCell + y0;
171 <        waterZ[ndx] = k * waterCell + z0;
172 <        ndx++;
173 <        
174 <        waterX[ndx] = i * waterCell + x0;
175 <        waterY[ndx] = j * waterCell + 0.5 * waterCell + y0;
176 <        waterZ[ndx] = k * waterCell + 0.5 * waterCell + z0;
177 <        ndx++;
178 <        
179 <        waterX[ndx] = i * waterCell + 0.5 * waterCell + x0;
180 <        waterY[ndx] = j * waterCell + y0;
181 <        waterZ[ndx] = k * waterCell + 0.5 * waterCell + z0;
182 <        ndx++;
184 >
185 >        myFCC.getLatticePoints(&posX, &posY, &posZ, i, j, k);
186 >        for(l=0; l<4; l++){
187 >          waterX[ndx]=posX[l];
188 >          waterY[ndx]=posY[l];
189 >          waterZ[ndx]=posZ[l];
190 >          ndx++;
191 >        }
192        }
193      }
194    }
# Line 202 | Line 211 | int buildRandomBilayer( void ){
211    testSite.pos[1] = 0.0;
212    testSite.pos[2] = 0.0;
213  
214 <  lipidLocate->placeMol( testSite.pos, testSite.rot, atoms, 0 );
214 >  lipidLocate->placeMol( testSite.pos, testSite.rot, atoms, 0, theConfig );
215  
216    int *isActive = new int[testWaters];
217    for(i=0; i<testWaters; i++) isActive[i] = 1;
# Line 214 | Line 223 | int buildRandomBilayer( void ){
223    
224    for(i=0; ( (i<testWaters) && isActive[i] ); i++){
225      for(j=0; ( (j<lipidNatoms) && isActive[i] ); j++){
226 +      
227 +      atoms[j]->getPos( pos );
228  
229 <      dx = waterX[i] - atoms[j]->getX();
230 <      dy = waterY[i] - atoms[j]->getY();
231 <      dz = waterZ[i] - atoms[j]->getZ();
229 >      dx = waterX[i] - pos[0];
230 >      dy = waterY[i] - pos[1];
231 >      dz = waterZ[i] - pos[2];
232  
233        buildMap( dx, dy, dz, testBox, testBox, testBox );
234  
235        dx2 = dx * dx;
236        dy2 = dy * dy;
237        dz2 = dz * dz;
238 <      
238 >          
239        dSqr = dx2 + dy2 + dz2;
240        if( dSqr < rCutSqr ){
241          isActive[i] = 0;
# Line 239 | Line 250 | int buildRandomBilayer( void ){
250  
251    // find the best box size for the sim
252  
253 +  int nCellsX, nCellsY, nCellsZ;
254 +
255 +  const double boxTargetX = 56;
256 +  const double boxTargetY = 41;
257 +
258 +  nCellsX = (int)ceil(boxTargetX / waterCell);
259 +  nCellsY = (int)ceil(boxTargetY / waterCell);
260 +  
261    int testTot;
262    int done = 0;
263 <  ndx = 0;
263 >  nCellsZ = 0;
264    while( !done ){
265 <    
266 <    ndx++;
267 <    testTot = 4 * ndx * ndx * ndx;
268 <    
265 >        
266 >    nCellsZ++;
267 >    testTot = 4 * nCellsX * nCellsY * nCellsZ;
268 >        
269      if( testTot >= targetWaters ) done = 1;
270    }
271  
253  nCells = ndx;
254    
255    
272    // create the new water box to the new specifications
273    
274 <  int newWaters = nCells * nCells * nCells * 4;
274 >  int newWaters = nCellsX * nCellsY * nCellsZ * 4;
275    
276    delete[] waterX;
277    delete[] waterY;
# Line 263 | Line 279 | int buildRandomBilayer( void ){
279    
280    coord* waterSites = new coord[newWaters];
281    
282 <  double box_x = waterCell * nCells;
283 <  double box_y = waterCell * nCells;
284 <  double box_z = waterCell * nCells;
285 <    
282 >  double box_x = waterCell * nCellsX;
283 >  double box_y = waterCell * nCellsY;
284 >  double box_z = waterCell * nCellsZ;
285 >        
286 >  
287 >
288    // create an fcc lattice in the water box.
289    
290    ndx = 0;
291 <  for( i=0; i < nCells; i++ ){
292 <    for( j=0; j < nCells; j++ ){
293 <      for( k=0; k < nCells; k++ ){
294 <        
295 <        waterSites[ndx].pos[0] = i * waterCell;
296 <        waterSites[ndx].pos[1] = j * waterCell;
297 <        waterSites[ndx].pos[2] = k * waterCell;
298 <        ndx++;
299 <        
300 <        waterSites[ndx].pos[0] = i * waterCell + 0.5 * waterCell;
301 <        waterSites[ndx].pos[1] = j * waterCell + 0.5 * waterCell;
284 <        waterSites[ndx].pos[2] = k * waterCell;
285 <        ndx++;
286 <        
287 <        waterSites[ndx].pos[0] = i * waterCell;
288 <        waterSites[ndx].pos[1] = j * waterCell + 0.5 * waterCell;
289 <        waterSites[ndx].pos[2] = k * waterCell + 0.5 * waterCell;
290 <        ndx++;
291 <        
292 <        waterSites[ndx].pos[0] = i * waterCell + 0.5 * waterCell;
293 <        waterSites[ndx].pos[1] = j * waterCell;
294 <        waterSites[ndx].pos[2] = k * waterCell + 0.5 * waterCell;
295 <        ndx++;
291 >  for( i=0; i < nCellsX; i++ ){
292 >    for( j=0; j < nCellsY; j++ ){
293 >      for( k=0; k < nCellsZ; k++ ){
294 >
295 >        myFCC.getLatticePoints(&posX, &posY, &posZ, i, j, k);
296 >        for(l=0; l<4; l++){
297 >          waterSites[ndx].pos[0] = posX[l];
298 >          waterSites[ndx].pos[1] = posY[l];
299 >          waterSites[ndx].pos[2] = posZ[l];
300 >          ndx++;
301 >        }
302        }
303      }
304    }  
# Line 305 | Line 311 | int buildRandomBilayer( void ){
311    int reject;
312    int testDX, acceptedDX;
313  
314 +  nAtoms = nLipids * lipidNatoms;
315 +
316 +  simnfo[1].n_atoms = nAtoms;
317 +  simnfo[1].atoms=new Atom*[nAtoms];
318 +
319 +  theConfig = simnfo[1].getConfiguration();
320 +  theConfig->createArrays( simnfo[1].n_atoms );
321 +
322 +  atoms=simnfo[1].atoms;
323 +
324    rCutSqr = lipid_spaceing * lipid_spaceing;
325  
326    for(i=0; i<nLipids; i++ ){
327      done = 0;
328      while( !done ){
329 <      
329 >          
330        lipidSites[i].pos[0] = drand48() * box_x;
331        lipidSites[i].pos[1] = drand48() * box_y;
332        lipidSites[i].pos[2] = drand48() * box_z;
333 <      
333 >          
334        getRandomRot( lipidSites[i].rot );
335 <      
335 >          
336        ndx = i * lipidNatoms;
337  
338        lipidLocate->placeMol( lipidSites[i].pos, lipidSites[i].rot, atoms,
339 <                             ndx );
340 <      
339 >                             ndx, theConfig );
340 >          
341        reject = 0;
342        for( j=0; !reject && j<i; j++){
343          for(k=0; !reject && k<lipidNatoms; k++){
344            
345            acceptedDX = j*lipidNatoms + k;
346            for(l=0; !reject && l<lipidNatoms; l++){
347 <            
347 >                
348              testDX = ndx + l;
349  
350 <            dx = atoms[testDX]->getX() - atoms[acceptedDX]->getX();
351 <            dy = atoms[testDX]->getY() - atoms[acceptedDX]->getY();
336 <            dz = atoms[testDX]->getZ() - atoms[acceptedDX]->getZ();
350 >            atoms[testDX]->getPos( posA );
351 >            atoms[acceptedDX]->getPos( posB );
352              
353 +            dx = posA[0] - posB[0];
354 +            dy = posA[1] - posB[1];
355 +            dz = posA[2] - posB[2];
356 +                
357              buildMap( dx, dy, dz, box_x, box_y, box_z );
358 <            
358 >                
359              dx2 = dx * dx;
360              dy2 = dy * dy;
361              dz2 = dz * dz;
362 <            
362 >                
363              dSqr = dx2 + dy2 + dz2;
364              if( dSqr < rCutSqr ) reject = 1;
365            }
# Line 353 | Line 372 | int buildRandomBilayer( void ){
372        }
373        else{
374          done = 1;
375 <        std::cout << i << " has been accepted\n";
375 >        std::cout << (i+1) << " has been accepted\n";
376        }
377      }
378    }
379          
380 +
381 +  // zSort of the lipid positions
382 +
383 +
384 +  vector< pair<int,double> >zSortArray;
385 +  for(i=0;i<nLipids;i++)
386 +    zSortArray.push_back( make_pair(i, lipidSites[i].pos[2]) );
387 +
388 +  sort(zSortArray.begin(),zSortArray.end(),SortCond());
389 +
390 +  ofstream outFile( "./zConBead3-01.bass", ios::app);
391 +
392 +  for(i=0; i<nLipids; i++){
393 +    outFile << "zConstraint[" << i << "]{\n"
394 +            << "  molIndex = " << zSortArray[i].first <<  ";\n"
395 +            << "  zPos = ";
396 +
397 +    if(i<32) outFile << "60.0;\n";
398 +    else outFile << "100.0;\n";
399 +
400 +    outFile << "  kRatio = 0.5;\n"
401 +            << "}\n";
402 +  }
403 +  
404 +  outFile.close();
405 +
406 +
407    // cut out the waters that overlap with the lipids.
408    
409 +
410    delete[] isActive;
411    isActive = new int[newWaters];
412    for(i=0; i<newWaters; i++) isActive[i] = 1;
# Line 369 | Line 416 | int buildRandomBilayer( void ){
416    for(i=0; ( (i<newWaters) && isActive[i] ); i++){
417      for(j=0; ( (j<nAtoms) && isActive[i] ); j++){
418  
419 <      dx = waterSites[i].pos[0] - atoms[j]->getX();
373 <      dy = waterSites[i].pos[1] - atoms[j]->getY();
374 <      dz = waterSites[i].pos[2] - atoms[j]->getZ();
419 >      atoms[j]->getPos( pos );
420  
421 +      dx = waterSites[i].pos[0] - pos[0];
422 +      dy = waterSites[i].pos[1] - pos[1];
423 +      dz = waterSites[i].pos[2] - pos[2];
424 +
425        buildMap( dx, dy, dz, box_x, box_y, box_z );
426  
427        dx2 = dx * dx;
428        dy2 = dy * dy;
429        dz2 = dz * dz;
430 <      
430 >          
431        dSqr = dx2 + dy2 + dz2;
432        if( dSqr < rCutSqr ){
433          isActive[i] = 0;
434          n_active--;
435 +
436 +
437        }
438      }
439    }
440  
441 +
442 +
443 +
444    if( n_active < nWaters ){
445 <    
445 >        
446      sprintf( painCave.errMsg,
447               "Too many waters were removed, edit code and try again.\n" );
448 <    
448 >        
449      painCave.isFatal = 1;
450      simError();
451    }
# Line 404 | Line 458 | int buildRandomBilayer( void ){
458      if( isActive[quickKill] ){
459        isActive[quickKill] = 0;
460        n_active--;
461 +
462      }
463    }
464  
465    if( n_active != nWaters ){
466 <    
466 >        
467      sprintf( painCave.errMsg,
468               "QuickKill didn't work right. n_active = %d, and nWaters = %d\n",
469               n_active, nWaters );
# Line 418 | Line 473 | int buildRandomBilayer( void ){
473  
474    // clean up our messes before building the final system.
475  
476 <  for(i=0; i<nAtoms; i++){
477 <    
423 <    delete atoms[i];
424 <  }
425 <  Atom::destroyArrays();
426 <  
476 >  simnfo[0].getConfiguration()->destroyArrays();
477 >  simnfo[1].getConfiguration()->destroyArrays();
478  
479    // create the real Atom arrays
480    
# Line 443 | Line 494 | int buildRandomBilayer( void ){
494      nAtoms += waterNatoms;
495    }
496    
497 +  theConfig = simnfo[2].getConfiguration();
498 +  theConfig->createArrays( nAtoms );
499 +  simnfo[2].atoms = new Atom*[nAtoms];
500 +  atoms = simnfo[2].atoms;
501 +  simnfo[2].n_atoms = nAtoms;
502    
447  Atom::createArrays( nAtoms );
448  atoms = new Atom*[nAtoms];
449
450  
503    // initialize lipid positions
504  
505    molIndex = 0;
506    for(i=0; i<nLipids; i++ ){
507      lipidLocate->placeMol( lipidSites[i].pos, lipidSites[i].rot, atoms,
508 <                           molStart[molIndex] );
508 >                           molStart[molIndex], theConfig );
509      molIndex++;
510    }
511  
512    // initialize the water positions
513  
514    for(i=0; i<newWaters; i++){
515 <    
515 >        
516      if( isActive[i] ){
517 <      
517 >          
518        getRandomRot( waterSites[i].rot );
519        waterLocate->placeMol( waterSites[i].pos, waterSites[i].rot, atoms,
520 <                             molStart[molIndex] );
520 >                             molStart[molIndex], theConfig );
521        molIndex++;
522      }
523    }  
524  
525    // set up the SimInfo object
526    
527 +  double Hmat[3][3];
528 +
529 +  Hmat[0][0] = box_x;
530 +  Hmat[0][1] = 0.0;
531 +  Hmat[0][2] = 0.0;
532 +
533 +  Hmat[1][0] = 0.0;
534 +  Hmat[1][1] = box_y;
535 +  Hmat[1][2] = 0.0;
536 +
537 +  Hmat[2][0] = 0.0;
538 +  Hmat[2][1] = 0.0;
539 +  Hmat[2][2] = box_z;
540 +  
541 +
542    bsInfo.boxX = box_x;
543    bsInfo.boxY = box_y;
544    bsInfo.boxZ = box_z;
545    
546 <  double boxVector[3];
480 <
481 <  boxVector[0] = bsInfo.boxX;
482 <  boxVector[1] = bsInfo.boxY;
483 <  boxVector[2] = bsInfo.boxZ;
484 <  simnfo->setBox( boxVector );
546 >  simnfo[2].setBoxM( Hmat );
547  
548 <  sprintf( simnfo->sampleName, "%s.dump", bsInfo.outPrefix );
549 <  sprintf( simnfo->finalName, "%s.init", bsInfo.outPrefix );
548 >  sprintf( simnfo[2].sampleName, "%s.dump", bsInfo.outPrefix );
549 >  sprintf( simnfo[2].finalName, "%s.init", bsInfo.outPrefix );
550  
489  simnfo->atoms = atoms;
490  
551    // set up the writer and write out
552    
553 <  writer = new DumpWriter( simnfo );
553 >  writer = new DumpWriter( &simnfo[2] );
554    writer->writeFinal( 0.0 );
495    
496  // clean up the memory
497  
498 //   if( molMap != NULL )   delete[] molMap;
499 //   if( cardDeck != NULL ) delete[] cardDeck;
500 //   if( locate != NULL ){
501 //     for(i=0; i<bsInfo.nComponents; i++){
502 //       delete locate[i];
503 //     }
504 //     delete[] locate;
505 //   }
506 //   if( atoms != NULL ){
507 //     for(i=0; i<nAtoms; i++){
508 //       delete atoms[i];
509 //     }
510 //     Atom::destroyArrays();
511 //     delete[] atoms;
512 //   }
513 //   if( molSeq != NULL ) delete[] molSeq;
514 //   if( simnfo != NULL ) delete simnfo;
515 //   if( writer != NULL ) delete writer;
516
517  return 1;
518 }
519
520  
521
522 int Old_buildRandomBilayer( void ){
523
524  int i,j,k;
525  int nAtoms, atomIndex, molIndex, molID;
526  int* molSeq;
527  int* molMap;
528  int* molStart;
529  int* cardDeck;
530  int deckSize;
531  int rSite, rCard;
532  double cell;
533  int nCells, nSites, siteIndex;
534  double rot[3][3];
535  double pos[3];
536
537  Atom** atoms;
538  SimInfo* simnfo;
539  DumpWriter* writer;
540  MoLocator** locate;
541
542  // initialize functions and variables
543  
544  srand48( RAND_SEED );
545  molSeq = NULL;
546  molStart = NULL;
547  molMap = NULL;
548  cardDeck = NULL;
549  atoms = NULL;
550  locate = NULL;
551  simnfo = NULL;
552  writer = NULL;
553
554  // calculate the number of cells in the fcc box
555
556  nCells = 0;
557  nSites = 0;
558  while( nSites < bsInfo.totNmol ){
559    nCells++;
560    nSites = 4.0 * pow( (double)nCells, 3.0 );
561  }
562
563
564  // create the molMap and cardDeck arrays
565  
566  molMap = new int[nSites];
567  cardDeck = new int[nSites];
568  
569  for(i=0; i<nSites; i++){
570    molMap[i] = -1;
571    cardDeck[i] = i;
572  }
573
574  // randomly place the molecules on the sites
575  
576  deckSize = nSites;
577  for(i=0; i<bsInfo.totNmol; i++){
578    rCard = (int)( deckSize * drand48() );
579    rSite = cardDeck[rCard];
580    molMap[rSite] = i;
581
582    // book keep the card deck;
583    
584    deckSize--;
585    cardDeck[rCard] = cardDeck[deckSize];
586  }
587  
588  
589  // create the MoLocator and Atom arrays
590  
591  nAtoms = 0;
592  molIndex = 0;
593  locate = new MoLocator*[bsInfo.nComponents];
594  molSeq = new int[bsInfo.totNmol];
595  molStart = new int[bsInfo.totNmol];  
596  for(i=0; i<bsInfo.nComponents; i++){
597    locate[i] = new MoLocator( bsInfo.compStamps[i] );
598    for(j=0; j<bsInfo.componentsNmol[i]; j++){
599      molSeq[molIndex] = i;
600      molStart[molIndex] = nAtoms;
601      molIndex++;
602      nAtoms += bsInfo.compStamps[i]->getNAtoms();
603    }
604  }
605  
606  Atom::createArrays( nAtoms );
607  atoms = new Atom*[nAtoms];
608  
609  
610  // place the molecules at each FCC site
611  
612  cell = 5.0;
613  for(i=0; i<bsInfo.nComponents; i++){
614    if(cell < locate[i]->getMaxLength() ) cell = locate[i]->getMaxLength();
615  }
616  cell *= 1.2; // add a little buffer
617
618  cell *= M_SQRT2;
619
620  siteIndex = 0;
621  for(i=0; i<nCells; i++){
622    for(j=0; j<nCells; j++){
623      for(k=0; k<nCells; k++){
555          
625        if( molMap[siteIndex] >= 0 ){
626          pos[0] = i * cell;
627          pos[1] = j * cell;
628          pos[2] = k * cell;
629          
630          getRandomRot( rot );
631          molID = molSeq[molMap[siteIndex]];
632          atomIndex = molStart[ molMap[siteIndex] ];
633          locate[molID]->placeMol( pos, rot, atoms, atomIndex );
634        }
635        siteIndex++;
636
637        if( molMap[siteIndex] >= 0 ){
638          pos[0] = i * cell + (0.5 * cell);
639          pos[1] = j * cell;
640          pos[2] = k * cell + (0.5 * cell);
641
642          getRandomRot( rot );
643          molID = molSeq[molMap[siteIndex]];
644          atomIndex = molStart[ molMap[siteIndex] ];
645          locate[molID]->placeMol( pos, rot, atoms, atomIndex );
646        }
647        siteIndex++;
648
649        if( molMap[siteIndex] >= 0 ){
650          pos[0] = i * cell + (0.5 * cell);
651          pos[1] = j * cell + (0.5 * cell);
652          pos[2] = k * cell;
653          
654          getRandomRot( rot );
655          molID = molSeq[molMap[siteIndex]];
656          atomIndex = molStart[ molMap[siteIndex] ];
657          locate[molID]->placeMol( pos, rot, atoms, atomIndex );
658        }
659        siteIndex++;
660
661        if( molMap[siteIndex] >= 0 ){
662          pos[0] = i * cell;
663          pos[1] = j * cell + (0.5 * cell);
664          pos[2] = k * cell + (0.5 * cell);
665
666          getRandomRot( rot );
667          molID = molSeq[molMap[siteIndex]];
668          atomIndex = molStart[ molMap[siteIndex] ];
669          locate[molID]->placeMol( pos, rot, atoms, atomIndex );
670        }
671        siteIndex++;
672      }
673    }
674  }
675
676  // set up the SimInfo object
677  
678  bsInfo.boxX = nCells * cell;
679  bsInfo.boxY = nCells * cell;
680  bsInfo.boxZ = nCells * cell;
681  
682  double boxVector[3];
683  simnfo = new SimInfo();
684  simnfo->n_atoms = nAtoms;
685  boxVector[0] = bsInfo.boxX;
686  boxVector[1] = bsInfo.boxY;
687  boxVector[2] = bsInfo.boxZ;
688  simnfo->setBox( boxVector );
689
690  sprintf( simnfo->sampleName, "%s.dump", bsInfo.outPrefix );
691  sprintf( simnfo->finalName, "%s.init", bsInfo.outPrefix );
692
693  simnfo->atoms = atoms;
694  
695  // set up the writer and write out
696  
697  writer = new DumpWriter( simnfo );
698  writer->writeFinal(0.0);
699    
556    // clean up the memory
557    
558 <  if( molMap != NULL )   delete[] molMap;
559 <  if( cardDeck != NULL ) delete[] cardDeck;
560 <  if( locate != NULL ){
561 <    for(i=0; i<bsInfo.nComponents; i++){
562 <      delete locate[i];
563 <    }
564 <    delete[] locate;
565 <  }
566 <  if( atoms != NULL ){
567 <    for(i=0; i<nAtoms; i++){
568 <      delete atoms[i];
569 <    }
570 <    Atom::destroyArrays();
571 <    delete[] atoms;
572 <  }
573 <  if( molSeq != NULL ) delete[] molSeq;
574 <  if( simnfo != NULL ) delete simnfo;
575 <  if( writer != NULL ) delete writer;
558 >  //     if( molMap != NULL )   delete[] molMap;
559 >  //     if( cardDeck != NULL ) delete[] cardDeck;
560 >  //     if( locate != NULL ){
561 >  //       for(i=0; i<bsInfo.nComponents; i++){
562 >  //             delete locate[i];
563 >  //       }
564 >  //       delete[] locate;
565 >  //     }
566 >  //     if( atoms != NULL ){
567 >  //       for(i=0; i<nAtoms; i++){
568 >  //             delete atoms[i];
569 >  //       }
570 >  //       Atom::destroyArrays();
571 >  //       delete[] atoms;
572 >  //     }
573 >  //     if( molSeq != NULL ) delete[] molSeq;
574 >  //     if( simnfo != NULL ) delete simnfo;
575 >  //     if( writer != NULL ) delete writer;
576  
577    return 1;
578   }
579  
724
580   void getRandomRot( double rot[3][3] ){
581  
582    double theta, phi, psi;
# Line 751 | Line 606 | void buildMap( double &x, double &y, double &z,
606  
607  
608   void buildMap( double &x, double &y, double &z,
609 <          double boxX, double boxY, double boxZ ){
609 >               double boxX, double boxY, double boxZ ){
610    
611    if(x < 0) x -= boxX * (double)( (int)( (x / boxX)  - 0.5 ) );
612    else x -= boxX * (double)( (int)( (x / boxX ) + 0.5));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines