| 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; |
| 51 |
> |
const double water_padding = 6.0; |
| 52 |
> |
const double lipid_spaceing = 8.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 ); |
| 224 |
|
|
| 225 |
|
int targetWaters = nWaters + n_deleted * nLipids; |
| 226 |
|
|
| 227 |
+ |
targetWaters = (int) ( targetWaters * 1.2 ); |
| 228 |
+ |
|
| 229 |
|
// find the best box size for the sim |
| 230 |
|
|
| 231 |
|
int testTot; |
| 305 |
|
done = 0; |
| 306 |
|
while( !done ){ |
| 307 |
|
|
| 308 |
< |
lipidSite[i].pos[0] = drand48() * box_x; |
| 309 |
< |
lipidSite[i].pos[1] = drand48() * box_y; |
| 310 |
< |
lipidSite[i].pos[2] = drand48() * box_z; |
| 308 |
> |
lipidSites[i].pos[0] = drand48() * box_x; |
| 309 |
> |
lipidSites[i].pos[1] = drand48() * box_y; |
| 310 |
> |
lipidSites[i].pos[2] = drand48() * box_z; |
| 311 |
|
|
| 312 |
< |
getRandomRot( lipidSite[i].rot ); |
| 312 |
> |
getRandomRot( lipidSites[i].rot ); |
| 313 |
|
|
| 314 |
|
ndx = i * lipidNatoms; |
| 315 |
|
|
| 316 |
< |
lipidLocate->placeMol( lipidSite[i].pos, lipidSite[i].rot, atoms, ndx ); |
| 316 |
> |
lipidLocate->placeMol( lipidSites[i].pos, lipidSites[i].rot, atoms, |
| 317 |
> |
ndx ); |
| 318 |
|
|
| 319 |
|
reject = 0; |
| 320 |
|
for( j=0; !reject && j<i; j++){ |
| 363 |
|
for(i=0; ( (i<newWaters) && isActive[i] ); i++){ |
| 364 |
|
for(j=0; ( (j<nAtoms) && isActive[i] ); j++){ |
| 365 |
|
|
| 366 |
< |
dx = waterSite[i].pos[0] - rsaAtoms[j]->getX(); |
| 367 |
< |
dy = waterSite[i].pos[1] - rsaAtoms[j]->getY(); |
| 368 |
< |
dz = waterSite[i].pos[2] - rsaAtoms[j]->getZ(); |
| 366 |
> |
dx = waterSites[i].pos[0] - atoms[j]->getX(); |
| 367 |
> |
dy = waterSites[i].pos[1] - atoms[j]->getY(); |
| 368 |
> |
dz = waterSites[i].pos[2] - atoms[j]->getZ(); |
| 369 |
|
|
| 370 |
|
map( dx, dy, dz, box_x, box_y, box_z ); |
| 371 |
|
|
| 423 |
|
|
| 424 |
|
nAtoms = 0; |
| 425 |
|
molIndex = 0; |
| 417 |
– |
locate = new MoLocator*[2]; |
| 418 |
– |
molSeq = new int[nLipids + nWaters]; |
| 426 |
|
molStart = new int[nLipids + nWaters]; |
| 427 |
|
|
| 421 |
– |
locate[0] = lipidLocate; |
| 428 |
|
for(j=0; j<nLipids; j++){ |
| 423 |
– |
molSeq[molIndex] = 0; |
| 429 |
|
molStart[molIndex] = nAtoms; |
| 430 |
|
molIndex++; |
| 431 |
|
nAtoms += lipidNatoms; |
| 432 |
|
} |
| 433 |
|
|
| 434 |
< |
locate[1] = waterLocate; |
| 430 |
< |
for(j=0; j<nLipids; j++){ |
| 431 |
< |
molSeq[molIndex] = 1; |
| 434 |
> |
for(j=0; j<nWaters; j++){ |
| 435 |
|
molStart[molIndex] = nAtoms; |
| 436 |
|
molIndex++; |
| 437 |
|
nAtoms += waterNatoms; |
| 444 |
|
|
| 445 |
|
// initialize lipid positions |
| 446 |
|
|
| 447 |
< |
|
| 448 |
< |
|
| 449 |
< |
|
| 447 |
> |
molIndex = 0; |
| 448 |
> |
for(i=0; i<nLipids; i++ ){ |
| 449 |
> |
lipidLocate->placeMol( lipidSites[i].pos, lipidSites[i].rot, atoms, |
| 450 |
> |
molStart[molIndex] ); |
| 451 |
> |
molIndex++; |
| 452 |
> |
} |
| 453 |
> |
|
| 454 |
> |
// initialize the water positions |
| 455 |
> |
|
| 456 |
> |
for(i=0; i<newWaters; i++){ |
| 457 |
> |
|
| 458 |
> |
if( isActive[i] ){ |
| 459 |
> |
|
| 460 |
> |
getRandomRot( waterSites[i].rot ); |
| 461 |
> |
waterLocate->placeMol( waterSites[i].pos, waterSites[i].rot, atoms, |
| 462 |
> |
molStart[molIndex] ); |
| 463 |
> |
molIndex++; |
| 464 |
> |
} |
| 465 |
> |
} |
| 466 |
|
|
| 467 |
|
// set up the SimInfo object |
| 468 |
|
|
| 470 |
|
bsInfo.boxY = box_y; |
| 471 |
|
bsInfo.boxZ = box_z; |
| 472 |
|
|
| 473 |
+ |
double boxVector[3]; |
| 474 |
|
simnfo = new SimInfo(); |
| 475 |
|
simnfo->n_atoms = nAtoms; |
| 476 |
< |
simnfo->box_x = bsInfo.boxX; |
| 477 |
< |
simnfo->box_y = bsInfo.boxY; |
| 478 |
< |
simnfo->box_z = bsInfo.boxZ; |
| 479 |
< |
|
| 476 |
> |
boxVector[0] = bsInfo.boxX; |
| 477 |
> |
boxVector[1] = bsInfo.boxY; |
| 478 |
> |
boxVector[2] = bsInfo.boxZ; |
| 479 |
> |
simnfo->setBox( boxVector ); |
| 480 |
> |
|
| 481 |
|
sprintf( simnfo->sampleName, "%s.dump", bsInfo.outPrefix ); |
| 482 |
|
sprintf( simnfo->finalName, "%s.init", bsInfo.outPrefix ); |
| 483 |
|
|
| 486 |
|
// set up the writer and write out |
| 487 |
|
|
| 488 |
|
writer = new DumpWriter( simnfo ); |
| 489 |
< |
writer->writeFinal(); |
| 489 |
> |
writer->writeFinal( 0.0 ); |
| 490 |
|
|
| 491 |
|
// clean up the memory |
| 492 |
|
|
| 493 |
< |
if( molMap != NULL ) delete[] molMap; |
| 494 |
< |
if( cardDeck != NULL ) delete[] cardDeck; |
| 495 |
< |
if( locate != NULL ){ |
| 496 |
< |
for(i=0; i<bsInfo.nComponents; i++){ |
| 497 |
< |
delete locate[i]; |
| 498 |
< |
} |
| 499 |
< |
delete[] locate; |
| 500 |
< |
} |
| 501 |
< |
if( atoms != NULL ){ |
| 502 |
< |
for(i=0; i<nAtoms; i++){ |
| 503 |
< |
delete atoms[i]; |
| 504 |
< |
} |
| 505 |
< |
Atom::destroyArrays(); |
| 506 |
< |
delete[] atoms; |
| 507 |
< |
} |
| 508 |
< |
if( molSeq != NULL ) delete[] molSeq; |
| 509 |
< |
if( simnfo != NULL ) delete simnfo; |
| 510 |
< |
if( writer != NULL ) delete writer; |
| 493 |
> |
// if( molMap != NULL ) delete[] molMap; |
| 494 |
> |
// if( cardDeck != NULL ) delete[] cardDeck; |
| 495 |
> |
// if( locate != NULL ){ |
| 496 |
> |
// for(i=0; i<bsInfo.nComponents; i++){ |
| 497 |
> |
// delete locate[i]; |
| 498 |
> |
// } |
| 499 |
> |
// delete[] locate; |
| 500 |
> |
// } |
| 501 |
> |
// if( atoms != NULL ){ |
| 502 |
> |
// for(i=0; i<nAtoms; i++){ |
| 503 |
> |
// delete atoms[i]; |
| 504 |
> |
// } |
| 505 |
> |
// Atom::destroyArrays(); |
| 506 |
> |
// delete[] atoms; |
| 507 |
> |
// } |
| 508 |
> |
// if( molSeq != NULL ) delete[] molSeq; |
| 509 |
> |
// if( simnfo != NULL ) delete simnfo; |
| 510 |
> |
// if( writer != NULL ) delete writer; |
| 511 |
|
|
| 512 |
|
return 1; |
| 513 |
|
} |
| 514 |
|
|
| 515 |
|
|
| 516 |
|
|
| 496 |
– |
|
| 497 |
– |
} |
| 498 |
– |
|
| 499 |
– |
|
| 500 |
– |
|
| 517 |
|
int Old_buildRandomBilayer( void ){ |
| 518 |
|
|
| 519 |
|
int i,j,k; |
| 674 |
|
bsInfo.boxY = nCells * cell; |
| 675 |
|
bsInfo.boxZ = nCells * cell; |
| 676 |
|
|
| 677 |
+ |
double boxVector[3]; |
| 678 |
|
simnfo = new SimInfo(); |
| 679 |
|
simnfo->n_atoms = nAtoms; |
| 680 |
< |
simnfo->box_x = bsInfo.boxX; |
| 681 |
< |
simnfo->box_y = bsInfo.boxY; |
| 682 |
< |
simnfo->box_z = bsInfo.boxZ; |
| 683 |
< |
|
| 680 |
> |
boxVector[0] = bsInfo.boxX; |
| 681 |
> |
boxVector[1] = bsInfo.boxY; |
| 682 |
> |
boxVector[2] = bsInfo.boxZ; |
| 683 |
> |
simnfo->setBox( boxVector ); |
| 684 |
> |
|
| 685 |
|
sprintf( simnfo->sampleName, "%s.dump", bsInfo.outPrefix ); |
| 686 |
|
sprintf( simnfo->finalName, "%s.init", bsInfo.outPrefix ); |
| 687 |
|
|
| 690 |
|
// set up the writer and write out |
| 691 |
|
|
| 692 |
|
writer = new DumpWriter( simnfo ); |
| 693 |
< |
writer->writeFinal(); |
| 693 |
> |
writer->writeFinal(0.0); |
| 694 |
|
|
| 695 |
|
// clean up the memory |
| 696 |
|
|