********> bugfix.22 Author: Bill Ross Date: 3/11/98 Programs: Leap Severity: Moderate Description: In solvateBox, solute can be placed off-center in the box. Fix: In tools.c, replace the ToolCenterUnitByRadii() routine by the following. --------------------------------------------------------------------------- FUNC void ToolCenterUnitByRadii( uUnit, bOrient ) UNIT uUnit; BOOL bOrient; { LOOP lTemp; ATOM aAtom; double dR, dXmin, dYmin, dZmin, dXmax, dYmax, dZmax; double dX, dY, dZ; VECTOR vPos; int iFirst = 1; BEGIN ToolSanityCheckBox( uUnit ); /* * if unit already has a box, it is assumed to be properly * set up already (e.g. orienting WATBOX216 here will * put its diagonals on the axes, and forcing the box * to be at the furthest vdw boundaries is not appropriate * for such a solvent because it is equilibrated in a * periodic system so that at the boundary, the vdw * spheres mesh) */ if ( bUnitUseBox( uUnit ) ) RETURNV; if ( bOrient == TRUE ) ToolOrientPrincipleAxisAlongCoordinateAxis( uUnit ); lTemp = lLoop( uUnit, ATOMS ); while ( aAtom = (ATOM)oNext(&lTemp) ) { dR = dToolAtomR( aAtom ); if ( dR < 0.1 ) { /* R unknown or 0 */ if ( iAtomElement( aAtom ) == HYDROGEN ) dR = 1.0; else dR = ATOM_DEFAULT_RADIUS; } aAtom->dTemp = dR; vPos = vAtomPosition(aAtom); dX = dVX(&vPos) + dR; dY = dVY(&vPos) + dR; dZ = dVZ(&vPos) + dR; if ( iFirst ) { dXmax = dX; dYmax = dY; dZmax = dZ; } else { if ( dX > dXmax ) dXmax = dX; if ( dY > dYmax ) dYmax = dY; if ( dZ > dZmax ) dZmax = dZ; } dX = dVX(&vPos) - dR; dY = dVY(&vPos) - dR; dZ = dVZ(&vPos) - dR; if ( iFirst ) { dXmin = dX; dYmin = dY; dZmin = dZ; iFirst = 0; } else { if ( dX < dXmin ) dXmin = dX; if ( dY < dYmin ) dYmin = dY; if ( dZ < dZmin ) dZmin = dZ; } } /* * define center of bounding box */ dX = dXmin + 0.5 * (dXmax - dXmin); dY = dYmin + 0.5 * (dYmax - dYmin); dZ = dZmin + 0.5 * (dZmax - dZmin); /* * translate center to origin */ VectorDef( &vPos, -dX, -dY, -dZ ); ContainerTranslateBy( uUnit, vPos ); UnitSetBox( uUnit, dXmax-dXmin, dYmax-dYmin, dZmax-dZmin ); END } ---------------------------------------------------------------------------