void VolumeTetrapore::update(){ if(boxout){ boxfile.printf("%d\n",8); const Tensor & t(getPbc().getBox()); if(getPbc().isOrthorombic()){ boxfile.printf(" %f %f %f\n",lenunit*t(0,0),lenunit*t(1,1),lenunit*t(2,2)); }else{ boxfile.printf(" %f %f %f %f %f %f %f %f %f\n", lenunit*t(0,0),lenunit*t(0,1),lenunit*t(0,2), lenunit*t(1,0),lenunit*t(1,1),lenunit*t(1,2), lenunit*t(2,0),lenunit*t(2,1),lenunit*t(2,2) ); } boxfile.printf("AR %f %f %f \n",lenunit*origin[0],lenunit*origin[1],lenunit*origin[2]); Vector ut, vt, wt; ut = origin + len_bi*bi; vt = origin + len_cross*cross; wt = origin + len_perp*perp; boxfile.printf("AR %f %f %f \n",lenunit*(ut[0]) , lenunit*(ut[1]), lenunit*(ut[2]) ); boxfile.printf("AR %f %f %f \n",lenunit*(vt[0]) , lenunit*(vt[1]), lenunit*(vt[2]) ); boxfile.printf("AR %f %f %f \n",lenunit*(wt[0]) , lenunit*(wt[1]), lenunit*(wt[2]) ); boxfile.printf("AR %f %f %f \n",lenunit*(vt[0]+len_bi*bi[0]), lenunit*(vt[1]+len_bi*bi[1]), lenunit*(vt[2]+len_bi*bi[2]) ); boxfile.printf("AR %f %f %f \n",lenunit*(ut[0]+len_perp*perp[0]), lenunit*(ut[1]+len_perp*perp[1]), lenunit*(ut[2]+len_perp*perp[2]) ); boxfile.printf("AR %f %f %f \n",lenunit*(vt[0]+len_perp*perp[0]), lenunit*(vt[1]+len_perp*perp[1]), lenunit*(vt[2]+len_perp*perp[2]) ); boxfile.printf("AR %f %f %f \n",lenunit*(vt[0]+len_perp*perp[0]+len_bi*bi[0]), lenunit*(vt[1]+len_perp*perp[1]+len_bi*bi[1]), lenunit*(vt[2]+len_perp*perp[2]+len_bi*bi[2]) ); } }
double Mapping::calculateDistanceFunction( const unsigned& ifunc, const bool& squared ){ // Calculate the distance double dd = mymap->calcDistanceFromConfiguration( ifunc, getPositions(), getPbc(), getArguments(), squared ); // Transform distance by whatever fframes[ifunc]=transformHD( dd, dfframes[ifunc] ); return fframes[ifunc]; }
void AdaptivePath::update() { double weight2 = -1.*mypathv->dx; double weight1 = 1.0 + mypathv->dx; if( weight1>1.0 ) { weight1=1.0; weight2=0.0; } else if( weight2>1.0 ) { weight1=0.0; weight2=1.0; } // Add projections to dispalcement accumulators ReferenceConfiguration* myref = getReferenceConfiguration( mypathv->iclose1 ); myref->extractDisplacementVector( getPositions(), getArguments(), mypathv->cargs, false, displacement ); getReferenceConfiguration( mypathv->iclose2 )->extractDisplacementVector( myref->getReferencePositions(), getArguments(), myref->getReferenceArguments(), false, displacement2 ); displacement.addDirection( -mypathv->dx, displacement2 ); pdisplacements[mypathv->iclose1].addDirection( weight1, displacement ); pdisplacements[mypathv->iclose2].addDirection( weight2, displacement ); // Update weight accumulators wsum[mypathv->iclose1] *= fadefact; wsum[mypathv->iclose2] *= fadefact; wsum[mypathv->iclose1] += weight1; wsum[mypathv->iclose2] += weight2; // This does the update of the path if it is time to if( (getStep()>0) && (getStep()%update_str==0) ) { wsum[fixedn[0]]=wsum[fixedn[1]]=0.; for(unsigned inode=0; inode<getNumberOfReferencePoints(); ++inode) { if( wsum[inode]>0 ) { // First displace the node by the weighted direction getReferenceConfiguration( inode )->displaceReferenceConfiguration( 1./wsum[inode], pdisplacements[inode] ); // Reset the displacement pdisplacements[inode].zeroDirection(); } } // Now ensure all the nodes of the path are equally spaced PathReparameterization myspacings( getPbc(), getArguments(), getAllReferenceConfigurations() ); myspacings.reparameterize( fixedn[0], fixedn[1], tolerance ); } if( (getStep()>0) && (getStep()%wstride==0) ) { pathfile.printf("# PATH AT STEP %d TIME %f \n", getStep(), getTime() ); std::vector<std::unique_ptr<ReferenceConfiguration>>& myconfs=getAllReferenceConfigurations(); std::vector<SetupMolInfo*> moldat=plumed.getActionSet().select<SetupMolInfo*>(); if( moldat.size()>1 ) error("you should only have one MOLINFO action in your input file"); SetupMolInfo* mymoldat=NULL; if( moldat.size()==1 ) mymoldat=moldat[0]; std::vector<std::string> argument_names( getNumberOfArguments() ); for(unsigned i=0; i<getNumberOfArguments(); ++i) argument_names[i] = getPntrToArgument(i)->getName(); PDB mypdb; mypdb.setArgumentNames( argument_names ); for(unsigned i=0; i<myconfs.size(); ++i) { pathfile.printf("REMARK TYPE=%s\n", myconfs[i]->getName().c_str() ); mypdb.setAtomPositions( myconfs[i]->getReferencePositions() ); for(unsigned j=0; j<getNumberOfArguments(); ++j) mypdb.setArgumentValue( getPntrToArgument(j)->getName(), myconfs[i]->getReferenceArgument(j) ); mypdb.print( atoms.getUnits().getLength()/0.1, mymoldat, pathfile, ofmt ); } pathfile.flush(); } }
void SecondaryStructureRMSD::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const { // Retrieve the positions std::vector<Vector> pos( references[0]->getNumberOfAtoms() ); const unsigned n=pos.size(); for(unsigned i=0;i<n;++i) pos[i]=ActionAtomistic::getPosition( getAtomIndex(current,i) ); // This does strands cutoff Vector distance=pbcDistance( pos[align_atom_1],pos[align_atom_2] ); if( s_cutoff2>0 ){ if( distance.modulo2()>s_cutoff2 ){ myvals.setValue( 0, 0.0 ); return; } } // This aligns the two strands if this is required if( alignType!="DRMSD" && align_strands ){ Vector origin_old, origin_new; origin_old=pos[align_atom_2]; origin_new=pos[align_atom_1]+distance; for(unsigned i=15;i<30;++i){ pos[i]+=( origin_new - origin_old ); } } // Create a holder for the derivatives ReferenceValuePack mypack( 0, pos.size(), myvals ); mypack.setValIndex( 1 ); for(unsigned i=0;i<n;++i) mypack.setAtomIndex( i, getAtomIndex(current,i) ); // And now calculate the RMSD const Pbc& pbc=getPbc(); unsigned closest=0; double r = references[0]->calculate( pos, pbc, mypack, false ); const unsigned rs = references.size(); for(unsigned i=1;i<rs;++i){ mypack.setValIndex( i+1 ); double nr=references[i]->calculate( pos, pbc, mypack, false ); if( nr<r ){ closest=i; r=nr; } } // Transfer everything to the value myvals.setValue( 0, 1.0 ); myvals.setValue( 1, r ); if( closest>0 ) mypack.moveDerivatives( closest+1, 1 ); if( !mypack.virialWasSet() ){ Tensor vir; const unsigned cacs = colvar_atoms[current].size(); for(unsigned i=0;i<cacs;++i){ vir+=(-1.0*Tensor( pos[i], mypack.getAtomDerivative(i) )); } mypack.setValIndex(1); mypack.addBoxDerivatives( vir ); } return; }
void AdaptivePath::update() { double weight2 = -1.*mypathv->dx; double weight1 = 1.0 + mypathv->dx; if( weight1>1.0 ) { weight1=1.0; weight2=0.0; } else if( weight2>1.0 ) { weight1=0.0; weight2=1.0; } // Add projections to dispalcement accumulators ReferenceConfiguration* myref = getReferenceConfiguration( mypathv->iclose1 ); myref->extractDisplacementVector( getPositions(), getArguments(), mypathv->cargs, false, displacement ); getReferenceConfiguration( mypathv->iclose2 )->extractDisplacementVector( myref->getReferencePositions(), getArguments(), myref->getReferenceArguments(), false, displacement2 ); displacement.addDirection( -mypathv->dx, displacement2 ); pdisplacements[mypathv->iclose1].addDirection( weight1, displacement ); pdisplacements[mypathv->iclose2].addDirection( weight2, displacement ); // Update weight accumulators wsum[mypathv->iclose1] *= fadefact; wsum[mypathv->iclose2] *= fadefact; wsum[mypathv->iclose1] += weight1; wsum[mypathv->iclose2] += weight2; // This does the update of the path if it is time to if( (getStep()>0) && (getStep()%update_str==0) ) { wsum[fixedn[0]]=wsum[fixedn[1]]=0.; for(unsigned inode=0; inode<getNumberOfReferencePoints(); ++inode) { if( wsum[inode]>0 ) { // First displace the node by the weighted direction getReferenceConfiguration( inode )->displaceReferenceConfiguration( 1./wsum[inode], pdisplacements[inode] ); // Reset the displacement pdisplacements[inode].zeroDirection(); } } // Now ensure all the nodes of the path are equally spaced PathReparameterization myspacings( getPbc(), getArguments(), getAllReferenceConfigurations() ); myspacings.reparameterize( fixedn[0], fixedn[1], tolerance ); } if( (getStep()>0) && (getStep()%wstride==0) ) { pathfile.printf("# PATH AT STEP %d TIME %f \n", getStep(), getTime() ); std::vector<ReferenceConfiguration*>& myconfs=getAllReferenceConfigurations(); for(unsigned i=0; i<myconfs.size(); ++i) myconfs[i]->print( pathfile, ofmt, atoms.getUnits().getLength()/0.1 ); pathfile.flush(); } }
void MultiColvarBase::setupLinkCells(){ if( !linkcells.enabled() ) return ; unsigned iblock, jblock; if( usespecies ){ iblock=0; } else if( current_atoms.size()<4 ){ iblock=1; } else { plumed_error(); } // Count number of currently active atoms unsigned nactive_atoms=0; for(unsigned i=0;i<ablocks[iblock].size();++i){ if( isCurrentlyActive( ablocks[iblock][i] ) ) nactive_atoms++; } std::vector<Vector> ltmp_pos( nactive_atoms ); std::vector<unsigned> ltmp_ind( nactive_atoms ); nactive_atoms=0; if( usespecies ){ ltmp_pos.resize( ablocks[0].size() ); ltmp_ind.resize( ablocks[0].size() ); for(unsigned i=0;i<ablocks[0].size();++i){ if( !isCurrentlyActive( ablocks[0][i] ) ) continue; ltmp_ind[nactive_atoms]=ablocks[0][i]; ltmp_pos[nactive_atoms]=getPositionOfAtomForLinkCells( ltmp_ind[nactive_atoms] ); nactive_atoms++; } } else { ltmp_pos.resize( ablocks[1].size() ); ltmp_ind.resize( ablocks[1].size() ); for(unsigned i=0;i<ablocks[1].size();++i){ if( !isCurrentlyActive( ablocks[1][i] ) ) continue; ltmp_ind[nactive_atoms]=i; ltmp_pos[nactive_atoms]=getPositionOfAtomForLinkCells( ablocks[1][i] ); nactive_atoms++; } } // Build the lists for the link cells linkcells.buildCellLists( ltmp_pos, ltmp_ind, getPbc() ); if( !usespecies ){ // Get some parallel info unsigned stride=comm.Get_size(); unsigned rank=comm.Get_rank(); if( serialCalculation() ){ stride=1; rank=0; } // Ensure we only do tasks where atoms are in appropriate link cells std::vector<unsigned> linked_atoms( 1+ablocks[1].size() ); std::vector<unsigned> active_tasks( getFullNumberOfTasks(), 0 ); for(unsigned i=rank;i<ablocks[0].size();i+=stride){ if( !isCurrentlyActive( ablocks[0][i] ) ) continue; natomsper=1; linked_atoms[0]=ltmp_ind[0]; // Note we always check atom 0 because it is simpler than changing LinkCells.cpp linkcells.retrieveNeighboringAtoms( getPositionOfAtomForLinkCells( ablocks[0][i] ), natomsper, linked_atoms ); for(unsigned j=0;j<natomsper;++j){ for(unsigned k=bookeeping(i,linked_atoms[j]).first;k<bookeeping(i,linked_atoms[j]).second;++k) active_tasks[k]=1; } } if( !serialCalculation() ) comm.Sum( active_tasks ); deactivateAllTasks(); activateTheseTasks( active_tasks ); contributorsAreUnlocked=false; } }
CoordinationBase::CoordinationBase(const ActionOptions&ao): PLUMED_COLVAR_INIT(ao), pbc(true), serial(false), invalidateList(true), firsttime(true) { parseFlag("SERIAL",serial); vector<AtomNumber> ga_lista,gb_lista; parseAtomList("GROUPA",ga_lista); parseAtomList("GROUPB",gb_lista); bool nopbc=!pbc; parseFlag("NOPBC",nopbc); pbc=!nopbc; // pair stuff bool dopair=false; parseFlag("PAIR",dopair); // neighbor list stuff bool doneigh=false; double nl_cut=0.0; int nl_st=0; parseFlag("NLIST",doneigh); if(doneigh) { parse("NL_CUTOFF",nl_cut); if(nl_cut<=0.0) error("NL_CUTOFF should be explicitly specified and positive"); parse("NL_STRIDE",nl_st); if(nl_st<=0) error("NL_STRIDE should be explicitly specified and positive"); } addValueWithDerivatives(); setNotPeriodic(); if(gb_lista.size()>0) { if(doneigh) nl= new NeighborList(ga_lista,gb_lista,dopair,pbc,getPbc(),nl_cut,nl_st); else nl= new NeighborList(ga_lista,gb_lista,dopair,pbc,getPbc()); } else { if(doneigh) nl= new NeighborList(ga_lista,pbc,getPbc(),nl_cut,nl_st); else nl= new NeighborList(ga_lista,pbc,getPbc()); } requestAtoms(nl->getFullAtomList()); log.printf(" between two groups of %u and %u atoms\n",static_cast<unsigned>(ga_lista.size()),static_cast<unsigned>(gb_lista.size())); log.printf(" first group:\n"); for(unsigned int i=0; i<ga_lista.size(); ++i) { if ( (i+1) % 25 == 0 ) log.printf(" \n"); log.printf(" %d", ga_lista[i].serial()); } log.printf(" \n second group:\n"); for(unsigned int i=0; i<gb_lista.size(); ++i) { if ( (i+1) % 25 == 0 ) log.printf(" \n"); log.printf(" %d", gb_lista[i].serial()); } log.printf(" \n"); if(pbc) log.printf(" using periodic boundary conditions\n"); else log.printf(" without periodic boundary conditions\n"); if(dopair) log.printf(" with PAIR option\n"); if(doneigh) { log.printf(" using neighbor lists with\n"); log.printf(" update every %d steps and cutoff %f\n",nl_st,nl_cut); } }
void MultiColvarBase::setupLinkCells(){ if( !linkcells.enabled() ) return ; unsigned iblock; if( usespecies ){ iblock=0; } else if( ablocks.size()<4 ){ iblock=1; } else { plumed_error(); } // Count number of currently active atoms unsigned nactive_atoms=0; for(unsigned i=0;i<ablocks[iblock].size();++i){ if( isCurrentlyActive( iblock, ablocks[iblock][i] ) ) nactive_atoms++; } std::vector<Vector> ltmp_pos( nactive_atoms ); std::vector<unsigned> ltmp_ind( nactive_atoms ); nactive_atoms=0; if( usespecies ){ for(unsigned i=0;i<ablocks[0].size();++i){ if( !isCurrentlyActive( 0, ablocks[0][i] ) ) continue; ltmp_ind[nactive_atoms]=ablocks[0][i]; ltmp_pos[nactive_atoms]=getPositionOfAtomForLinkCells( ltmp_ind[nactive_atoms] ); nactive_atoms++; } } else { for(unsigned i=0;i<ablocks[1].size();++i){ if( !isCurrentlyActive( 1, ablocks[1][i] ) ) continue; ltmp_ind[nactive_atoms]=i; ltmp_pos[nactive_atoms]=getPositionOfAtomForLinkCells( ablocks[1][i] ); nactive_atoms++; } } // Build the lists for the link cells linkcells.buildCellLists( ltmp_pos, ltmp_ind, getPbc() ); if( !usespecies ){ // Get some parallel info unsigned stride=comm.Get_size(); unsigned rank=comm.Get_rank(); if( serialCalculation() ){ stride=1; rank=0; } // Ensure we only do tasks where atoms are in appropriate link cells std::vector<unsigned> linked_atoms( 1+ablocks[1].size() ); std::vector<unsigned> active_tasks( getFullNumberOfTasks(), 0 ); for(unsigned i=rank;i<ablocks[0].size();i+=stride){ if( !isCurrentlyActive( 0, ablocks[0][i] ) ) continue; unsigned natomsper=1; linked_atoms[0]=ltmp_ind[0]; // Note we always check atom 0 because it is simpler than changing LinkCells.cpp linkcells.retrieveNeighboringAtoms( getPositionOfAtomForLinkCells( ablocks[0][i] ), natomsper, linked_atoms ); for(unsigned j=0;j<natomsper;++j){ for(unsigned k=bookeeping(i,linked_atoms[j]).first;k<bookeeping(i,linked_atoms[j]).second;++k) active_tasks[k]=1; } } if( !serialCalculation() ) comm.Sum( active_tasks ); deactivateAllTasks(); activateTheseTasks( active_tasks ); contributorsAreUnlocked=false; } else { // Now check for calculating volumes (currently this is only done for usespecies style commands // as it is difficult to do with things like DISTANCES or ANGLES and I think pointless bool justVolumes=true; for(unsigned i=0;i<getNumberOfVessels();++i){ vesselbase::BridgeVessel* myb=dynamic_cast<vesselbase::BridgeVessel*>( getPntrToVessel(i) ); if( !myb ){ justVolumes=false; break; } ActionVolume* myv=dynamic_cast<ActionVolume*>( myb->getOutputAction() ); if( !myv ){ justVolumes=false; break; } } // Now ensure that we only do calculations for those atoms in the relevant volume if( justVolumes ){ bool justVolumes=true; // Setup the regions in the action volume objects for(unsigned i=0;i<getNumberOfVessels();++i){ vesselbase::BridgeVessel* myb=dynamic_cast<vesselbase::BridgeVessel*>( getPntrToVessel(i) ); ActionVolume* myv=dynamic_cast<ActionVolume*>( myb->getOutputAction() ); myv->retrieveAtoms(); myv->setupRegions(); } unsigned stride=comm.Get_size(); unsigned rank=comm.Get_rank(); if( serialCalculation() ){ stride=1; rank=0; } unsigned nactive=0; std::vector<unsigned> active_tasks( getFullNumberOfTasks(), 0 ); for(unsigned i=rank;i<getFullNumberOfTasks();i+=stride){ bool invol=false; for(unsigned j=0;j<getNumberOfVessels();++j){ vesselbase::BridgeVessel* myb=dynamic_cast<vesselbase::BridgeVessel*>( getPntrToVessel(j) ); ActionVolume* myv=dynamic_cast<ActionVolume*>( myb->getOutputAction() ); if( myv->inVolumeOfInterest(i) ){ invol=true; } } if( invol ){ nactive++; active_tasks[i]=1; } } if( !serialCalculation() ) comm.Sum( active_tasks ); deactivateAllTasks(); activateTheseTasks( active_tasks ); contributorsAreUnlocked=false; } } }