45 |
|
|
46 |
|
|
47 |
|
const double waterRho = 0.0334; // number density per cubic angstrom |
48 |
< |
const double waterVol = 4.0 / water_rho; // volume occupied by 4 waters |
48 |
> |
const double waterVol = 4.0 / waterRho; // volume occupied by 4 waters |
49 |
|
const double waterCell = 4.929; // fcc unit cell length |
50 |
|
|
51 |
|
const double water_padding = 2.5; |
52 |
|
const double lipid_spaceing = 5.0; |
53 |
|
|
54 |
|
|
55 |
< |
int i,j,k; |
55 |
> |
int i,j,k, l; |
56 |
|
int nAtoms, atomIndex, molIndex, molID; |
57 |
|
int* molSeq; |
58 |
|
int* molMap; |
65 |
|
|
66 |
|
coord testSite; |
67 |
|
|
68 |
+ |
Atom** atoms; |
69 |
+ |
SimInfo* simnfo; |
70 |
+ |
DumpWriter* writer; |
71 |
+ |
|
72 |
|
MoleculeStamp* lipidStamp; |
73 |
|
MoleculeStamp* waterStamp; |
74 |
|
MoLocator *lipidLocate; |
75 |
< |
MoLocator *waterLocate |
75 |
> |
MoLocator *waterLocate; |
76 |
|
int foundLipid, foundWater; |
77 |
< |
int nLipids, lipiNatoms, nWaters, waterNatoms; |
77 |
> |
int nLipids, lipidNatoms, nWaters, waterNatoms; |
78 |
|
double testBox, maxLength; |
79 |
|
|
80 |
|
srand48( RAND_SEED ); |
83 |
|
// set the the lipidStamp |
84 |
|
|
85 |
|
foundLipid = 0; |
86 |
+ |
foundWater = 0; |
87 |
|
for(i=0; i<bsInfo.nComponents; i++){ |
88 |
|
if( !strcmp( bsInfo.compStamps[i]->getID(), bsInfo.lipidName ) ){ |
89 |
|
|
90 |
< |
foundlipid = 1; |
90 |
> |
foundLipid = 1; |
91 |
|
lipidStamp = bsInfo.compStamps[i]; |
92 |
|
nLipids = bsInfo.componentsNmol[i]; |
93 |
|
} |
94 |
|
if( !strcmp( bsInfo.compStamps[i]->getID(), bsInfo.waterName ) ){ |
95 |
|
|
96 |
|
foundWater = 1; |
97 |
+ |
|
98 |
|
waterStamp = bsInfo.compStamps[i]; |
99 |
|
nWaters = bsInfo.componentsNmol[i]; |
100 |
|
} |
121 |
|
maxLength = lipidLocate->getMaxLength(); |
122 |
|
|
123 |
|
waterLocate = new MoLocator( waterStamp ); |
124 |
< |
waterNatoms = waterStamp->getNatoms(); |
124 |
> |
waterNatoms = waterStamp->getNAtoms(); |
125 |
|
|
126 |
|
nAtoms = nLipids * lipidNatoms; |
127 |
|
|
131 |
|
// create the test box for initial water displacement |
132 |
|
|
133 |
|
testBox = maxLength + waterCell * 4.0; // pad with 4 cells |
134 |
< |
int nCells = (int)( testBox / waterCell + 1.0 ); |
134 |
> |
nCells = (int)( testBox / waterCell + 1.0 ); |
135 |
|
int testWaters = 4 * nCells * nCells * nCells; |
136 |
|
|
137 |
|
double* waterX = new double[testWaters]; |
138 |
< |
double* waterX = new double[testWaters]; |
139 |
< |
double* waterX = new double[testWaters]; |
138 |
> |
double* waterY = new double[testWaters]; |
139 |
> |
double* waterZ = new double[testWaters]; |
140 |
|
|
141 |
|
double x0 = 0.0 - ( testBox * 0.5 ); |
142 |
|
double y0 = 0.0 - ( testBox * 0.5 ); |
303 |
|
done = 0; |
304 |
|
while( !done ){ |
305 |
|
|
306 |
< |
lipidSite[i].pos[0] = drand48() * box_x; |
307 |
< |
lipidSite[i].pos[1] = drand48() * box_y; |
308 |
< |
lipidSite[i].pos[2] = drand48() * box_z; |
306 |
> |
lipidSites[i].pos[0] = drand48() * box_x; |
307 |
> |
lipidSites[i].pos[1] = drand48() * box_y; |
308 |
> |
lipidSites[i].pos[2] = drand48() * box_z; |
309 |
|
|
310 |
< |
getRandomRot( lipidSite[i].rot ); |
310 |
> |
getRandomRot( lipidSites[i].rot ); |
311 |
|
|
312 |
|
ndx = i * lipidNatoms; |
313 |
|
|
314 |
< |
lipidLocate->placeMol( lipidSite[i].pos, lipidSite[i].rot, atoms, ndx ); |
314 |
> |
lipidLocate->placeMol( lipidSites[i].pos, lipidSites[i].rot, atoms, |
315 |
> |
ndx ); |
316 |
|
|
317 |
|
reject = 0; |
318 |
|
for( j=0; !reject && j<i; j++){ |
361 |
|
for(i=0; ( (i<newWaters) && isActive[i] ); i++){ |
362 |
|
for(j=0; ( (j<nAtoms) && isActive[i] ); j++){ |
363 |
|
|
364 |
< |
dx = waterSite[i].pos[0] - rsaAtoms[j]->getX(); |
365 |
< |
dy = waterSite[i].pos[1] - rsaAtoms[j]->getY(); |
366 |
< |
dz = waterSite[i].pos[2] - rsaAtoms[j]->getZ(); |
364 |
> |
dx = waterSites[i].pos[0] - atoms[j]->getX(); |
365 |
> |
dy = waterSites[i].pos[1] - atoms[j]->getY(); |
366 |
> |
dz = waterSites[i].pos[2] - atoms[j]->getZ(); |
367 |
|
|
368 |
|
map( dx, dy, dz, box_x, box_y, box_z ); |
369 |
|
|
421 |
|
|
422 |
|
nAtoms = 0; |
423 |
|
molIndex = 0; |
417 |
– |
locate = new MoLocator*[2]; |
418 |
– |
molSeq = new int[nLipids + nWaters]; |
424 |
|
molStart = new int[nLipids + nWaters]; |
425 |
|
|
421 |
– |
locate[0] = lipidLocate; |
426 |
|
for(j=0; j<nLipids; j++){ |
423 |
– |
molSeq[molIndex] = 0; |
427 |
|
molStart[molIndex] = nAtoms; |
428 |
|
molIndex++; |
429 |
|
nAtoms += lipidNatoms; |
430 |
|
} |
431 |
|
|
432 |
< |
locate[1] = waterLocate; |
430 |
< |
for(j=0; j<nLipids; j++){ |
431 |
< |
molSeq[molIndex] = 1; |
432 |
> |
for(j=0; j<nWaters; j++){ |
433 |
|
molStart[molIndex] = nAtoms; |
434 |
|
molIndex++; |
435 |
|
nAtoms += waterNatoms; |
442 |
|
|
443 |
|
// initialize lipid positions |
444 |
|
|
445 |
< |
|
446 |
< |
|
447 |
< |
|
445 |
> |
molIndex = 0; |
446 |
> |
for(i=0; i<nLipids; i++ ){ |
447 |
> |
lipidLocate->placeMol( lipidSites[i].pos, lipidSites[i].rot, atoms, |
448 |
> |
molStart[molIndex] ); |
449 |
> |
molIndex++; |
450 |
> |
} |
451 |
|
|
452 |
+ |
// initialize the water positions |
453 |
+ |
|
454 |
+ |
for(i=0; i<newWaters; i++){ |
455 |
+ |
|
456 |
+ |
if( isActive[i] ){ |
457 |
+ |
|
458 |
+ |
getRandomRot( waterSites[i].rot ); |
459 |
+ |
waterLocate->placeMol( waterSites[i].pos, waterSites[i].rot, atoms, |
460 |
+ |
molStart[molIndex] ); |
461 |
+ |
molIndex++; |
462 |
+ |
} |
463 |
+ |
} |
464 |
+ |
|
465 |
|
// set up the SimInfo object |
466 |
|
|
467 |
|
bsInfo.boxX = box_x; |
486 |
|
|
487 |
|
// clean up the memory |
488 |
|
|
489 |
< |
if( molMap != NULL ) delete[] molMap; |
490 |
< |
if( cardDeck != NULL ) delete[] cardDeck; |
491 |
< |
if( locate != NULL ){ |
492 |
< |
for(i=0; i<bsInfo.nComponents; i++){ |
493 |
< |
delete locate[i]; |
494 |
< |
} |
495 |
< |
delete[] locate; |
496 |
< |
} |
497 |
< |
if( atoms != NULL ){ |
498 |
< |
for(i=0; i<nAtoms; i++){ |
499 |
< |
delete atoms[i]; |
500 |
< |
} |
501 |
< |
Atom::destroyArrays(); |
502 |
< |
delete[] atoms; |
503 |
< |
} |
504 |
< |
if( molSeq != NULL ) delete[] molSeq; |
505 |
< |
if( simnfo != NULL ) delete simnfo; |
506 |
< |
if( writer != NULL ) delete writer; |
489 |
> |
// if( molMap != NULL ) delete[] molMap; |
490 |
> |
// if( cardDeck != NULL ) delete[] cardDeck; |
491 |
> |
// if( locate != NULL ){ |
492 |
> |
// for(i=0; i<bsInfo.nComponents; i++){ |
493 |
> |
// delete locate[i]; |
494 |
> |
// } |
495 |
> |
// delete[] locate; |
496 |
> |
// } |
497 |
> |
// if( atoms != NULL ){ |
498 |
> |
// for(i=0; i<nAtoms; i++){ |
499 |
> |
// delete atoms[i]; |
500 |
> |
// } |
501 |
> |
// Atom::destroyArrays(); |
502 |
> |
// delete[] atoms; |
503 |
> |
// } |
504 |
> |
// if( molSeq != NULL ) delete[] molSeq; |
505 |
> |
// if( simnfo != NULL ) delete simnfo; |
506 |
> |
// if( writer != NULL ) delete writer; |
507 |
|
|
508 |
|
return 1; |
509 |
|
} |
510 |
|
|
511 |
|
|
512 |
|
|
496 |
– |
|
497 |
– |
} |
498 |
– |
|
499 |
– |
|
500 |
– |
|
513 |
|
int Old_buildRandomBilayer( void ){ |
514 |
|
|
515 |
|
int i,j,k; |