// Action_Density::HistAction() Action::RetType Action_Density::HistAction(int frameNum, ActionFrame& frm) { long int bin = 0; // Loop over masks for (unsigned int idx = 0; idx != masks_.size(); ++idx) { AtomMask const& mask = masks_[idx]; HistType& hist = histograms_[idx]; std::map<long int, double> Sum; // Loop over mask atoms unsigned int midx = 0; for (AtomMask::const_iterator atm = mask.begin(); atm != mask.end(); ++atm, midx++) { const double* XYZ = frm.Frm().XYZ( *atm ); if (XYZ[axis_] < 0) { // Coordinate is negative. Need to subtract off delta so that proper bin // is populated (-delta to 0.0). bin = (XYZ[axis_] - delta_) / delta_; } else { // Coordinate is positive. bin = XYZ[axis_] / delta_; } //mprintf("DEBUG: frm=%6i mask=%3u atm=%8i crd=%8.3f bin=%li\n", frameNum+1, idx, *atm+1, XYZ[axis_], bin); Sum[bin] += properties_[idx][midx]; } // Accumulate sums hist.accumulate( Sum ); } // Accumulate area Box const& box = frm.Frm().BoxCrd(); area_.accumulate(box[area_coord_[0]] * box[area_coord_[1]]); return Action::OK; }
// Action_Distance::DoAction() Action::RetType Action_Distance::DoAction(int frameNum, ActionFrame& frm) { double Dist; Matrix_3x3 ucell, recip; Vec3 a1, a2; if (useMass_) { a1 = frm.Frm().VCenterOfMass( Mask1_ ); a2 = frm.Frm().VCenterOfMass( Mask2_ ); } else { a1 = frm.Frm().VGeometricCenter( Mask1_ ); a2 = frm.Frm().VGeometricCenter( Mask2_ ); } switch ( image_.ImageType() ) { case NONORTHO: frm.Frm().BoxCrd().ToRecip(ucell, recip); Dist = DIST2_ImageNonOrtho(a1, a2, ucell, recip); break; case ORTHO: Dist = DIST2_ImageOrtho(a1, a2, frm.Frm().BoxCrd()); break; case NOIMAGE: Dist = DIST2_NoImage(a1, a2); break; } Dist = sqrt(Dist); dist_->Add(frameNum, &Dist); return Action::OK; }
int ActionNode::getFirstFrameIndex() { int frameindex = 99999; bool bFindFrame = false; for (int n = 0; n < _frameArrayNum; n++) { Array* cArray = (Array*)(_frameArray->getObjectAtIndex(n)); if (cArray == NULL || cArray->count() <= 0) { continue; } bFindFrame = true; ActionFrame* frame = (ActionFrame*)(cArray->getObjectAtIndex(0)); int iFrameIndex = frame->getFrameIndex(); if (frameindex > iFrameIndex) { frameindex = iFrameIndex; } } if (!bFindFrame) { frameindex = 0; } return frameindex; }
Action::RetType Action_AtomicCorr::DoAction(int frameNum, ActionFrame& frm) { // On first pass through refframe will be empty and first frame will become ref. if (!previousFrame_.empty()) { ACvector::iterator atom_vector = atom_vectors_.begin(); if (acorr_mode_ == ATOM) { // For each atom in mask, calc delta position. for (AtomMask::const_iterator atom = mask_.begin(); atom != mask_.end(); ++atom) { const double* tgtxyz = frm.Frm().XYZ( *atom ); const double* refxyz = previousFrame_.XYZ( *atom ); atom_vector->push_back( (float)(tgtxyz[0] - refxyz[0]) ); atom_vector->push_back( (float)(tgtxyz[1] - refxyz[1]) ); atom_vector->push_back( (float)(tgtxyz[2] - refxyz[2]) ); ++atom_vector; } } else { for (std::vector<AtomMask>::const_iterator rmask = resmasks_.begin(); rmask != resmasks_.end(); ++rmask) { Vec3 CXYZ = frm.Frm().VGeometricCenter( *rmask ); Vec3 RXYZ = previousFrame_.VGeometricCenter( *rmask ); atom_vector->push_back( (float)(CXYZ[0] - RXYZ[0]) ); atom_vector->push_back( (float)(CXYZ[1] - RXYZ[1]) ); atom_vector->push_back( (float)(CXYZ[2] - RXYZ[2]) ); ++atom_vector; } } } // Store this frame as new reference frame previousFrame_ = frm.Frm(); return Action::OK; }
// Action_CreateReservoir::DoAction() Action::RetType Action_CreateReservoir::DoAction(int frameNum, ActionFrame& frm) { int bin = -1; if (bin_ != 0) bin = (int)bin_->Dval(frm.TrajoutNum()); if (reservoir_.WriteReservoir(nframes_++, frm.Frm(), ene_->Dval(frm.TrajoutNum()), bin)) return Action::ERR; return Action::OK; }
int ActionNode::getLastFrameIndex() { int frameindex = -1; bool bFindFrame = false; for (int n = 0; n < frameArrayNum; n++) { CCArray* cArray = (CCArray*)(m_FrameArray->objectAtIndex(n)); if (cArray == NULL || cArray->count() <= 0) { continue; } bFindFrame = true; int lastInex = cArray->count() - 1; ActionFrame* frame = (ActionFrame*)(cArray->objectAtIndex(lastInex)); int iFrameIndex = frame->getFrameIndex(); if (frameindex < iFrameIndex) { frameindex = iFrameIndex; } } if (!bFindFrame) { frameindex = 0; } return frameindex; }
// Action_Principal::DoAction() Action::RetType Action_Principal::DoAction(int frameNum, ActionFrame& frm) { Matrix_3x3 Inertia; Vec3 Eval; frm.Frm().CalculateInertia( mask_, Inertia ); // NOTE: Diagonalize_Sort_Chirality places sorted eigenvectors in rows. Inertia.Diagonalize_Sort_Chirality( Eval, debug_ ); if (outfile_ != 0) { int fn = frameNum+1; outfile_->Printf("%i EIGENVALUES: %f %f %f\n%i EIGENVECTOR 0: %f %f %f\n%i EIGENVECTOR 1: %f %f %f\n%i EIGENVECTOR 2: %f %f %f\n", fn, Eval[0], Eval[1], Eval[2], fn, Inertia[0], Inertia[1], Inertia[2], fn, Inertia[3], Inertia[4], Inertia[5], fn, Inertia[6], Inertia[7], Inertia[8]); //Eval.Print("PRINCIPAL EIGENVALUES"); //Inertia.Print("PRINCIPAL EIGENVECTORS (Rows)"); } if (vecData_ != 0) { vecData_->AddMat3x3( Inertia ); valData_->AddVxyz( Eval ); } // Rotate - since Evec is already transposed (eigenvectors // are returned in rows) just do plain rotation to affect an // inverse rotation. if (doRotation_) { frm.ModifyFrm().Rotate( Inertia ); return Action::MODIFY_COORDS; } return Action::OK; }
// Action_CheckStructure::DoAction() Action::RetType Action_CheckStructure::DoAction(int frameNum, ActionFrame& frm) { int total_problems = CheckOverlap(frameNum+1, frm.Frm(), *CurrentParm_); if (bondcheck_) total_problems += CheckBonds(frameNum+1, frm.Frm(), *CurrentParm_); if (total_problems > 0 && skipBadFrames_) return Action::SUPPRESS_COORD_OUTPUT; return Action::OK; }
/** Called every time a frame is read in. Calc distance RMSD. * If first is true, set the first frame read in as reference. */ Action::RetType Action_DistRmsd::DoAction(int frameNum, ActionFrame& frm) { // Perform any needed reference actions refHolder_.ActionRef( frm.Frm(), false, false ); // Set selected frame atoms. Masses have already been set. SelectedTgt_.SetCoordinates(frm.Frm(), TgtMask_); double DR = SelectedTgt_.DISTRMSD( refHolder_.SelectedRef() ); drmsd_->Add(frameNum, &DR); return Action::OK; }
// Action_DihedralScan::DoAction() Action::RetType Action_DihedralScan::DoAction(int frameNum, ActionFrame& frm) { switch (mode_) { case RANDOM: RandomizeAngles(frm.ModifyFrm()); break; case INTERVAL: IntervalAngles(frm.ModifyFrm()); break; } // Check the resulting structure int n_problems = checkStructure_.CheckOverlap( frameNum+1, frm.Frm(), *CurrentParm_ ); //mprintf("%i\tResulting structure has %i problems.\n",frameNum,n_problems); number_of_problems_->Add(frameNum, &n_problems); return Action::OK; }
Spawn * ActionNode::refreshActionProperty() { if ( _object == NULL ) { return NULL; } Array* cSpawnArray = Array::create(); for (int n = 0; n < _frameArrayNum; n++) { Array* cArray = (Array*)(_frameArray->getObjectAtIndex(n)); if (cArray == NULL || cArray->count() <= 0) { continue; } Array* cSequenceArray = Array::create(); int frameCount = cArray->count(); for (int i = 0; i < frameCount; i++) { ActionFrame* frame = (ActionFrame*)(cArray->getObjectAtIndex(i)); if (i == 0) { } else { ActionFrame* srcFrame = (ActionFrame*)(cArray->getObjectAtIndex(i-1)); float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime(); Action* cAction = frame->getAction(duration); cSequenceArray->addObject(cAction); } } Sequence* cSequence = Sequence::create(cSequenceArray); if (cSequence != NULL) { cSpawnArray->addObject(cSequence); } } if (_action == NULL) { CC_SAFE_RELEASE_NULL(_actionSpawn); } else { CC_SAFE_RELEASE_NULL(_action); } _actionSpawn = Spawn::create(cSpawnArray); CC_SAFE_RETAIN(_actionSpawn); return _actionSpawn; }
// Action_Density::DensityAction() Action::RetType Action_Density::DensityAction(int frameNum, ActionFrame& frm) { Matrix_3x3 ucell, recip; double volume = 0.0; if (image_.ImageType() == ORTHO) volume = frm.Frm().BoxCrd().BoxX() * frm.Frm().BoxCrd().BoxY() * frm.Frm().BoxCrd().BoxZ(); else if (image_.ImageType() == NONORTHO) volume = frm.Frm().BoxCrd().ToRecip( ucell, recip ); // Total mass is in delta_ double density = delta_ / (volume * AMU_ANG_TO_G_CM3); density_->Add(frameNum, &density); return Action::OK; }
/** If a dataset was specified for maxmin, check if this structure * satisfies the criteria; if so, write. Otherwise just write. */ Action::RetType Action_Outtraj::DoAction(int frameNum, ActionFrame& frm) { // If dataset defined, check if frame is within max/min if (!Dsets_.empty()) { for (unsigned int ds = 0; ds < Dsets_.size(); ++ds) { double dVal = Dsets_[ds]->Dval(frameNum); //mprintf("DBG: maxmin[%u]: dVal = %f, min = %f, max = %f\n",ds,dVal,Min_[ds],Max_[ds]); // If value from dataset not within min/max, exit now. if (dVal < Min_[ds] || dVal > Max_[ds]) return Action::OK; } } if (outtraj_.WriteSingle(frm.TrajoutNum(), frm.Frm())) return Action::ERR; return Action::OK; }
// Action_LIE::action() Action::RetType Action_LIE::DoAction(int frameNum, ActionFrame& frm) { if (doelec_) { double e = Calculate_Elec(frm.Frm()); elec_->Add(frameNum, &e); } if (dovdw_) { double e = Calculate_LJ(frm.Frm(), *CurrentParm_); vdw_->Add(frameNum, &e); } return Action::OK; }
bool ActionNode::updateActionToTimeLine(float fTime) { bool bFindFrame = false; ActionFrame* srcFrame = nullptr; // ActionFrame* destFrame = nullptr; for (int n = 0; n < _frameArrayNum; n++) { auto cArray = _frameArray.at(n); if (cArray->empty()) { continue; } ssize_t frameCount = cArray->size(); for (int i = 0; i < frameCount; i++) { auto frame = cArray->at(i); if (frame->getFrameIndex()*getUnitTime() == fTime) { this->easingToFrame(1.0f,1.0f,nullptr,frame); bFindFrame = true; break; } else if (frame->getFrameIndex()*getUnitTime() > fTime) { if (i == 0) { this->easingToFrame(1.0f,1.0f,nullptr,frame); bFindFrame = false; } else { srcFrame = cArray->at(i-1); float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex())*getUnitTime(); float delaytime = fTime - srcFrame->getFrameIndex()*getUnitTime(); this->easingToFrame(duration,1.0f,nullptr,srcFrame); //float easingTime = ActionFrameEasing::bounceTime(delaytime); this->easingToFrame(duration,delaytime/duration,srcFrame,frame); bFindFrame = true; } break; } } } return bFindFrame; }
// Action_ClusterDihedral::DoAction() Action::RetType Action_ClusterDihedral::DoAction(int frameNum, ActionFrame& frm) { // For each dihedral, calculate which bin it should go into and store bin# int bidx = 0; for (std::vector<DCmask>::const_iterator dih = DCmasks_.begin(); dih != DCmasks_.end(); ++dih) { double PHI = Torsion( frm.Frm().XYZ(dih->A1()), frm.Frm().XYZ(dih->A2()), frm.Frm().XYZ(dih->A3()), frm.Frm().XYZ(dih->A4()) ); // NOTE: Torsion is in radians; should bins be converted to rads as well? PHI *= Constants::RADDEG; //mprintf("[%6i]Dihedral=%8.3f", dih->A1(), PHI); // DEBUG PHI -= dih->Min(); //mprintf(" Shifted=%8.3f", PHI); // DEBUG if (PHI < 0) PHI += 360; //mprintf(" Wrapped=%8.3f", PHI); // DEBUG PHI /= dih->Step(); int phibin = (int)PHI; //mprintf(" Bin=%3i\n", phibin); // DEBUG Bins_[bidx++] = phibin; } // DEBUG - print bins //mprintf("["); //for (std::vector<int>::const_iterator bin = Bins_.begin(); bin != Bins_.end(); ++bin) // mprintf("%3i,",*bin); //mprintf("]\n"); // Now search for this bin combo in the DCarray std::vector<DCnode>::iterator DC = dcarray_.begin(); for (; DC != dcarray_.end(); ++DC) { if ( DC->BinMatch( Bins_ ) ) break; } if (DC == dcarray_.end()) { // No match; create new bin combo and store frame num //mprintf("NEW DCNODE.\n"); dcarray_.push_back( DCnode( Bins_, frameNum ) ); } else { // Match; increment bin count and store frame num //mprintf("DCNODE ALREADY PRESENT.\n"); DC->Increment(); DC->AddFrame( frameNum ); } // Store frame number lastframe_ = frameNum; return Action::OK; }
// Action_Unwrap::DoAction() Action::RetType Action_Unwrap::DoAction(int frameNum, ActionFrame& frm) { Matrix_3x3 ucell, recip; // Set reference structure if not already set if (RefFrame_.empty()) { RefFrame_ = frm.Frm(); return Action::OK; } if (orthogonal_) Image::UnwrapOrtho( frm.ModifyFrm(), RefFrame_, imageList_, center_, true ); else { frm.Frm().BoxCrd().ToRecip( ucell, recip ); Image::UnwrapNonortho( frm.ModifyFrm(), RefFrame_, imageList_, ucell, recip, center_, true ); } return Action::MODIFY_COORDS; }
// Action_Density::DoAction() Action::RetType Action_Density::DoAction(int frameNum, ActionFrame& frm) { long slice; unsigned long i, j; Vec3 coord; Box box; i = 0; for (std::vector<AtomMask>::const_iterator mask = masks_.begin(); mask != masks_.end(); mask++) { j = 0; std::map<long,double> minus_histo, plus_histo; for (AtomMask::const_iterator idx = mask->begin(); idx != mask->end(); idx++) { coord = frm.Frm().XYZ(*idx); slice = (unsigned long) (coord[axis_] / delta_); if (coord[axis_] < 0) { minus_histo[slice] += properties_[i][j]; } else { plus_histo[slice] += properties_[i][j]; } j++; } if (minus_histo.size() > 0) minus_histograms_[i].accumulate(minus_histo); if (plus_histo.size() > 0) plus_histograms_[i].accumulate(plus_histo); i++; } box = frm.Frm().BoxCrd(); area_.accumulate(box[area_coord_[0]] * box[area_coord_[1]]); return Action::OK; }
// Action_MultiVector::DoAction() Action::RetType Action_MultiVector::DoAction(int frameNum, ActionFrame& frm) { for (unsigned int nv = 0; nv < CrdIdx1_.size(); ++nv) { Vec3 CXYZ( frm.Frm().CRD( CrdIdx1_[nv] ) ); Vec3 VXYZ( frm.Frm().CRD( CrdIdx2_[nv] ) ); VXYZ -= CXYZ; data_[nv]->AddVxyz(VXYZ, CXYZ); } return Action::OK; }
// Action_Angle::action() Action::RetType Action_Angle::DoAction(int frameNum, ActionFrame& frm) { Vec3 a1, a2, a3; if (useMass_) { a1 = frm.Frm().VCenterOfMass( Mask1_ ); a2 = frm.Frm().VCenterOfMass( Mask2_ ); a3 = frm.Frm().VCenterOfMass( Mask3_ ); } else { a1 = frm.Frm().VGeometricCenter( Mask1_ ); a2 = frm.Frm().VGeometricCenter( Mask2_ ); a3 = frm.Frm().VGeometricCenter( Mask3_ ); } double aval = CalcAngle( a1.Dptr(), a2.Dptr(), a3.Dptr() ); aval *= Constants::RADDEG; ang_->Add(frameNum, &aval); return Action::OK; }
/** Center coordinates in frame according to specified mode. */ Action::RetType Action_Center::DoAction(int frameNum, ActionFrame& frm) { Vec3 center; if (useMass_) center = frm.Frm().VCenterOfMass(Mask_); else center = frm.Frm().VGeometricCenter(Mask_); //mprinterr(" FRAME CENTER: %lf %lf %lf\n",center[0],center[1],center[2]); //DEBUG switch (centerMode_) { case ORIGIN: // Shift to coordinate origin (0,0,0) center.Neg(); break; case BOXCTR: // Shift to box center center = frm.Frm().BoxCrd().Center() - center; break; case POINT: // Shift to specified point case REF: // Shift to reference point center = refCenter_ - center; break; } frm.ModifyFrm().Translate(center); return Action::MODIFY_COORDS; }
// Action_Esander::DoAction() Action::RetType Action_Esander::DoAction(int frameNum, ActionFrame& frm) { if (refFrame_.empty()) { refFrame_ = frm.Frm(); if ( InitForRef() ) return Action::ERR; } if (save_forces_) { newFrame_.SetCoordAndBox( frm.Frm() ); SANDER_.CalcEnergyForces( newFrame_ ); frm.SetFrame( &newFrame_ ); } else // FIXME: Passing in ModifyFrm() to give CalcEnergy access to non-const pointers SANDER_.CalcEnergy( frm.ModifyFrm() ); for (int ie = 0; ie != (int)Energy_Sander::N_ENERGYTYPES; ie++) { if (Esets_[ie] != 0) Esets_[ie]->Add(frameNum, SANDER_.Eptr((Energy_Sander::Etype)ie)); } return ret_; }
// Action_ReplicateCell::DoAction() Action::RetType Action_ReplicateCell::DoAction(int frameNum, ActionFrame& frm) { int idx, newFrameIdx; unsigned int id; Vec3 frac, t2; frm.Frm().BoxCrd().ToRecip(ucell_, recip_); int shift = Mask1_.Nselected() * 3; # ifdef _OPENMP # pragma omp parallel private(idx, newFrameIdx, id) firstprivate(frac, t2) { # pragma omp for # endif for (idx = 0; idx < Mask1_.Nselected(); idx++) { // Convert to fractional coords frac = recip_ * Vec3(frm.Frm().XYZ( Mask1_[idx] )); //mprintf("DEBUG: Atom %i frac={ %g %g %g }\n", Mask1_[idx]+1, frac[0], frac[1], frac[2]); // replicate in each direction newFrameIdx = idx * 3; for (id = 0; id != directionArray_.size(); id+=3, newFrameIdx += shift) { // Convert back to Cartesian coords. t2 = ucell_.TransposeMult(frac + Vec3(directionArray_[id ], directionArray_[id+1], directionArray_[id+2])); combinedFrame_[newFrameIdx ] = t2[0]; combinedFrame_[newFrameIdx+1] = t2[1]; combinedFrame_[newFrameIdx+2] = t2[2]; } } # ifdef _OPENMP } # endif if (writeTraj_) { if (outtraj_.WriteSingle(frm.TrajoutNum(), combinedFrame_) !=0 ) return Action::ERR; } if (coords_ != 0) coords_->AddFrame( combinedFrame_ ); return Action::OK; }
// Action_NMRrst::DoAction() Action::RetType Action_NMRrst::DoAction(int frameNum, ActionFrame& frm) { double Dist; Vec3 a1, a2; if (Image_.ImageType() == NONORTHO) frm.Frm().BoxCrd().ToRecip(ucell_, recip_); // NOEs from file. for (noeDataArray::iterator noe = NOEs_.begin(); noe != NOEs_.end(); ++noe) { if ( noe->active_ ) { if (useMass_) { a1 = frm.Frm().VCenterOfMass( noe->dMask1_ ); a2 = frm.Frm().VCenterOfMass( noe->dMask2_ ); } else { a1 = frm.Frm().VGeometricCenter( noe->dMask1_ ); a2 = frm.Frm().VGeometricCenter( noe->dMask2_ ); } switch ( Image_.ImageType() ) { case NONORTHO: Dist = DIST2_ImageNonOrtho(a1, a2, ucell_, recip_); break; case ORTHO: Dist = DIST2_ImageOrtho(a1, a2, frm.Frm().BoxCrd()); break; case NOIMAGE: Dist = DIST2_NoImage(a1, a2); break; } Dist = sqrt(Dist); noe->dist_->Add(frameNum, &Dist); } } // Find NOEs ProcessNoeArray( noeArray_, frm.Frm(), frameNum ); // Specified NOEs ProcessNoeArray( specifiedNOEs_, frm.Frm(), frameNum ); ++nframes_; return Action::OK; }
// Action_SymmetricRmsd::DoAction() Action::RetType Action_SymmetricRmsd::DoAction(int frameNum, ActionFrame& frm) { // Perform any needed reference actions REF_.ActionRef( frm.Frm(), SRMSD_.Fit(), SRMSD_.UseMass() ); // Calculate symmetric RMSD selectedTgt_.SetCoordinates( frm.Frm(), tgtMask_ ); double rmsdval = SRMSD_.SymmRMSD_CenteredRef( selectedTgt_, REF_.SelectedRef() ); rmsd_->Add(frameNum, &rmsdval); if (remap_) { // Now re-map the target frame for (int atom = 0; atom < (int)targetMap_.size(); atom++) targetMap_[atom] = atom; SymmetricRmsdCalc::Iarray const& AMap = SRMSD_.AMap(); for (unsigned int ref = 0; ref < AMap.size(); ++ref) targetMap_[ tgtMask_[ref] ] = tgtMask_[AMap[ref]]; remapFrame_.SetCoordinatesByMap( frm.Frm(), targetMap_ ); frm.SetFrame( &remapFrame_ ); } if ( SRMSD_.Fit() ) frm.ModifyFrm().Trans_Rot_Trans( SRMSD_.TgtTrans(), SRMSD_.RotMatrix(), REF_.RefTrans() ); return action_return_; }
/** Modify the current frame based on the atom map. */ Action::RetType Action_AtomMap::DoAction(int frameNum, ActionFrame& frm) { if (maponly_) return Action::OK; // Perform RMS fit on mapped atoms only if (rmsfit_) { // Set target frame up according to atom map. rmsTgtFrame_.ModifyByMap(frm.Frm(), AMap_); Matrix_3x3 Rot; Vec3 Trans, refTrans; double R = rmsTgtFrame_.RMSD(rmsRefFrame_, Rot, Trans, refTrans, false); frm.ModifyFrm().Trans_Rot_Trans(Trans, Rot, refTrans); if (rmsdata_!=0) rmsdata_->Add(frameNum, &R); return Action::OK; } // Modify the current frame // TODO: Fix this since its probably busted for unmapped atoms newFrame_->SetCoordinatesByMap(frm.Frm(), AMap_); frm.SetFrame( newFrame_ ); return Action::MODIFY_COORDS; }
// Action_NativeContacts::DoAction() Action::RetType Action_NativeContacts::DoAction(int frameNum, ActionFrame& frm) { if (image_.ImageType() == NONORTHO) frm.Frm().BoxCrd().ToRecip(ucell_, recip_); if (first_) { mprintf("\tUsing first frame to determine native contacts.\n"); if (DetermineNativeContacts( *CurrentParm_, frm.Frm() )) return Action::ERR; first_ = false; } nframes_++; // Loop over all potential contacts int Nnative = 0; int NnonNative = 0; double maxDist2 = 0.0; double minDist2 = DBL_MAX; if ( Mask2_.MaskStringSet() ) { for (int c1 = 0; c1 != Mask1_.Nselected(); c1++) for (int c2 = 0; c2 != Mask2_.Nselected(); c2++) { UpdateNativeContact(Mask1_, Mask2_, contactIdx1_, contactIdx2_); } } else { for (int c1 = 0; c1 != Mask1_.Nselected(); c1++) for (int c2 = c1 + 1; c2 != Mask1_.Nselected(); c2++) { UpdateNativeContact(Mask1_, Mask1_, contactIdx1_, contactIdx1_); } } numnative_->Add(frameNum, &Nnative); nonnative_->Add(frameNum, &NnonNative); if (mindist_ != 0) { minDist2 = sqrt(minDist2); mindist_->Add(frameNum, &minDist2); } if (maxdist_ != 0) { maxDist2 = sqrt(maxDist2); maxdist_->Add(frameNum, &maxDist2); } return Action::OK; }
// Action_VelocityAutoCorr::DoAction() Action::RetType Action_VelocityAutoCorr::DoAction(int frameNum, ActionFrame& frm) { if (!useVelInfo_) { // Calculate pseudo-velocities between frames. if (!previousFrame_.empty()) { // This is the first frame which we can calculate pseudo-velocity. VelArray::iterator vel = Vel_.begin(); for (AtomMask::const_iterator atom = mask_.begin(); atom != mask_.end(); ++atom, ++vel) vel->AddVxyz( (Vec3(frm.Frm().XYZ(*atom)) - Vec3(previousFrame_.XYZ(*atom))) / tstep_ ); } previousFrame_ = frm.Frm(); } else { // Use velocity information in the frame. // FIXME: Eventually dont assume V is in Amber units. VelArray::iterator vel = Vel_.begin(); for (AtomMask::const_iterator atom = mask_.begin(); atom != mask_.end(); ++atom, ++vel) vel->AddVxyz( Vec3(frm.Frm().VXYZ( *atom )) * Constants::AMBERTIME_TO_PS ); } return Action::OK; }
/** For each dihedral defined in JcouplingInfo, perform the dihedral and * Jcoupling calculation. */ Action::RetType Action_Jcoupling::DoAction(int frameNum, ActionFrame& frm) { double Jval; if (outputfile_ != 0) outputfile_->Printf("#Frame %i\n",frameNum+1); for (std::vector<jcouplingInfo>::iterator jc = JcouplingInfo_.begin(); jc !=JcouplingInfo_.end(); ++jc) { double phi = Torsion(frm.Frm().XYZ(jc->atom[0]), frm.Frm().XYZ(jc->atom[1]), frm.Frm().XYZ(jc->atom[2]), frm.Frm().XYZ(jc->atom[3]) ); if (jc->type==1) { //phitemp = phi + jc->C[3]; // Only necessary if offsets become used in perez-type calc Jval = jc->C[0] + (jc->C[1] * cos(phi)) + (jc->C[2] * cos(phi * 2.0)); } else { double phitemp = cos( phi + jc->C[3] ); Jval = (jc->C[0] * phitemp * phitemp) + (jc->C[1] * phitemp) + jc->C[2]; } float fval = (float)Jval; jc->data_->Add(frameNum, &fval); int residue = jc->residue; // Output if (outputfile_ != 0) outputfile_->Printf("%5i %4s%4s%4s%4s%4s%12f%12f\n", residue+1, CurrentParm_->Res(residue).c_str(), (*CurrentParm_)[jc->atom[0]].c_str(), (*CurrentParm_)[jc->atom[1]].c_str(), (*CurrentParm_)[jc->atom[2]].c_str(), (*CurrentParm_)[jc->atom[3]].c_str(), phi*Constants::RADDEG, Jval); } return Action::OK; }
// Action_Pairwise::DoAction() Action::RetType Action_Pairwise::DoAction(int frameNum, ActionFrame& frm) { // Reset cumulative energy arrays atom_eelec_.assign(CurrentParm_->Natom(), 0.0); atom_evdw_.assign(CurrentParm_->Natom(), 0.0); if (Eout_ != 0) Eout_->Printf("PAIRWISE: Frame %i\n",frameNum); NonbondEnergy( frm.Frm(), *CurrentParm_, Mask0_ ); nframes_++; // Write cumulative energy arrays if (PrintCutAtoms( frm.Frm(), frameNum, VDWOUT, atom_evdw_, cut_evdw_ )) return Action::ERR; if (PrintCutAtoms( frm.Frm(), frameNum, ELECOUT, atom_eelec_, cut_eelec_ )) return Action::ERR; // Write PDB with atoms that satisfy cutoff colored in. if (PdbOut_.IsOpen()) { PdbOut_.WriteMODEL(frameNum + 1); for (AtomMask::const_iterator atom = Mask0_.begin(); atom != Mask0_.end(); ++atom) { float occ = 0.0; float bfac = 0.0; if (fabs(atom_evdw_[*atom]) > cut_evdw_) occ = (float)atom_evdw_[*atom]; if (fabs(atom_eelec_[*atom]) > cut_eelec_) bfac = (float)atom_eelec_[*atom]; const double* XYZ = frm.Frm().XYZ( *atom ); Atom const& AT = (*CurrentParm_)[*atom]; int rn = AT.ResNum(); PdbOut_.WriteCoord(PDBfile::ATOM, *atom+1, AT.c_str(), CurrentParm_->Res(rn).c_str(), rn + 1, XYZ[0], XYZ[1], XYZ[2], occ, bfac, AT.ElementName(), (int)AT.Charge()); } PdbOut_.WriteENDMDL(); } ds_vdw_->Add(frameNum, &ELJ_); ds_elec_->Add(frameNum, &Eelec_); return Action::OK; }