コード例 #1
0
void InterpolateBicubic::set_table( const std::vector<Value>& ff ){
  plumed_assert( getNumberOfSplinePoints()==ff.size() ); 
  plumed_assert( ff[0].getNumberOfDerivatives()==2 );

  dcross=0.0; unsigned iplus, iminus;
  for(unsigned i=1;i<np[0]-1;++i){
      iplus=(i+1)*stride[0]; iminus=(i-1)*stride[0];
      for(unsigned j=1;j<np[1]-1;++j){
          dcross(i,j) = ( ff[iplus+j+1].get() + ff[iminus+j-1].get() - ff[iplus+j-1].get() - ff[iminus+j+1].get() ) /
                          getCrossTermDenominator( i, j );
      }
  } 

  double d1, d2; Matrix<double> tc(4,4);
  std::vector<double> y(4), dy1(4), dy2(4), d2y12(4);

  unsigned pij=0; unsigned ipos;
  for (unsigned i=0;i<np[0]-1;++i){
      ipos=i*stride[0]; d1 = getPointSpacing( 0, i );    
      for (unsigned j=0; j<np[1]-1;++j){
         d2 = getPointSpacing( 1, j );                   
         y[0] = ff[ipos+j].get(); y[1] = ff[ipos+stride[0]+j].get(); y[2] = ff[ipos+stride[0]+j+1].get(); y[3] = ff[ipos+j+1].get();
         dy1[0] = ff[ipos+j].getDerivative(0); dy1[1] = ff[ipos+stride[0]+j].getDerivative(0); 
         dy1[2] = ff[ipos+stride[0]+j+1].getDerivative(0); dy1[3] = ff[ipos+j+1].getDerivative(0);
         dy2[0] = ff[ipos+j].getDerivative(1); dy2[1] = ff[ipos+stride[0]+j].getDerivative(1); 
         dy2[2] = ff[ipos+stride[0]+j+1].getDerivative(1); dy2[3] = ff[ipos+j+1].getDerivative(1);
         d2y12[0] = dcross( i, j ); d2y12[1] = dcross( i+1, j ); d2y12[2] = dcross( i+1, j+1 ); d2y12[3] = dcross( i, j+1 );
         IBicCoeff( y, dy1, dy2, d2y12, d1, d2, tc);

         pij=( ipos+j )*16;
         for(unsigned k=0; k<4; ++k){ for(unsigned n=0; n<4; ++n){ clist[pij++]=tc(k,n); } }
      }
  }
}
コード例 #2
0
void ActionWithInputVessel::readArgument( const std::string& type ) {
  std::string mlab;
  if( keywords.exists("DATA") && type!="grid" ) parse("DATA",mlab);
  ActionWithVessel* mves= plumed.getActionSet().selectWithLabel<ActionWithVessel*>(mlab);
  if(!mves) error("action labelled " +  mlab + " does not exist or does not have vessels");
  addDependency(mves);

  ActionWithValue* aval=dynamic_cast<ActionWithValue*>( this );
  if(aval) {
    if( aval->checkNumericalDerivatives() ) {
      ActionWithValue* aval2=dynamic_cast<ActionWithValue*>( mves );
      plumed_assert( aval2 ); aval2->useNumericalDerivatives();
    }
  }

  if( type=="bridge" ) {
    ActionWithVessel* aves=dynamic_cast<ActionWithVessel*>( this );
    plumed_assert(aves); myBridgeVessel = mves->addBridgingVessel( aves );
    arguments = dynamic_cast<Vessel*>( myBridgeVessel );
  } else  if( type=="store" ) {
    arguments = dynamic_cast<Vessel*>( mves->buildDataStashes( NULL ) );
  } else {
    plumed_error();
  }
}
コード例 #3
0
ファイル: ActionWithVessel.cpp プロジェクト: apoma/plumed2
void ActionWithVessel::addTaskToList( const unsigned& taskCode ){
  plumed_assert( functions.size()==0 );  // We cannot add more tasks after vessels added
  indexOfTaskInFullList.push_back( fullTaskList.size() );
  fullTaskList.push_back( taskCode ); partialTaskList.push_back( taskCode ); 
  taskFlags.push_back(0); nactive_tasks = fullTaskList.size();
  plumed_assert( partialTaskList.size()==nactive_tasks && indexOfTaskInFullList.size()==nactive_tasks && taskFlags.size()==nactive_tasks );
}
コード例 #4
0
ファイル: PlumedMain.cpp プロジェクト: JFDama/plumed2
void PlumedMain::readInputWords(const std::vector<std::string> & words) {
  plumed_assert(initialized);
  if(words.empty())return;
  else if(words[0]=="ENDPLUMED") return;
  else if(words[0]=="_SET_SUFFIX") {
    plumed_assert(words.size()==2);
    setSuffix(words[1]);
  } else {
    std::vector<std::string> interpreted(words);
    Tools::interpretLabel(interpreted);
    Action* action=actionRegister().create(ActionOptions(*this,interpreted));
    if(!action) {
      log<<"ERROR\n";
      log<<"I cannot understand line:";
      for(unsigned i=0; i<interpreted.size(); ++i) log<<" "<<interpreted[i];
      log<<"\n";
      log.flush();
      plumed_merror("I cannot understand line " + interpreted[0] + " " + interpreted[1]);
    };
    action->checkRead();
    actionSet.push_back(action);
  };

  pilots=actionSet.select<ActionPilot*>();
}
コード例 #5
0
ファイル: LinkCells.cpp プロジェクト: GaganDhanoa/plumed2
void LinkCells::buildCellLists( const std::vector<Vector>& pos, const std::vector<unsigned>& indices, const Pbc& pbc ){
  plumed_assert( cutoffwasset && pos.size()==indices.size() );

  // Must be able to check that pbcs are not nonsensical in some way?? -- GAT

  // Setup the pbc object by copying it from action
  mypbc.setBox( pbc.getBox() );

  // Setup the lists
  if( pos.size()!=allcells.size() ){ 
    allcells.resize( pos.size() ); lcell_lists.resize( pos.size() ); 
  }

   {
// This is the reciprocal lattice
// notice that reciprocal.getRow(0) is a vector that is orthogonal to b and c
// This allows to use linked cells in non orthorhomic boxes
     Tensor reciprocal(transpose(mypbc.getInvBox()));
     ncells[0] = std::floor( 1.0/ reciprocal.getRow(0).modulo() / link_cutoff );
     if( ncells[0]==0 ) ncells[0]=1;
     ncells[1] = std::floor( 1.0/ reciprocal.getRow(1).modulo() / link_cutoff );
     if( ncells[1]==0 ) ncells[1]=1;
     ncells[2] = std::floor( 1.0/ reciprocal.getRow(2).modulo() / link_cutoff );
     if( ncells[2]==0 ) ncells[2]=1;
  }
  // Setup the strides
  nstride[0]=1; nstride[1]=ncells[0]; nstride[2]=ncells[0]*ncells[1];

  // Setup the storage for link cells
  unsigned ncellstot=ncells[0]*ncells[1]*ncells[2];
  if( lcell_tots.size()!=ncellstot ){
      lcell_tots.resize( ncellstot ); lcell_starts.resize( ncellstot );
  }
  // Clear nlcells
  for(unsigned i=0;i<ncellstot;++i) lcell_tots[i]=0;
  // Clear allcells
  allcells.assign( allcells.size(), 0 );

  // Find out what cell everyone is in
  unsigned rank=comm.Get_rank(), size=comm.Get_size();
  for(unsigned i=rank;i<pos.size();i+=size){
      allcells[i]=findCell( pos[i] );
      lcell_tots[allcells[i]]++;
  }
  // And gather all this information on every node
  comm.Sum( allcells ); comm.Sum( lcell_tots );

  // Now prepare the link cell lists
  unsigned tot=0;
  for(unsigned i=0;i<lcell_tots.size();++i){ lcell_starts[i]=tot; tot+=lcell_tots[i]; lcell_tots[i]=0; }
  plumed_assert( tot==pos.size() );

  // And setup the link cells properly
  for(unsigned j=0;j<pos.size();++j){
      unsigned myind = lcell_starts[ allcells[j] ] + lcell_tots[ allcells[j] ];
      lcell_lists[ myind ] = indices[j];
      lcell_tots[allcells[j]]++;
  }
}
コード例 #6
0
void BridgeVessel::completeNumericalDerivatives(){
  unsigned nextra = myOutputAction->getNumberOfDerivatives() - getAction()->getNumberOfDerivatives();
  Matrix<double> tmpder( myOutputValues->getNumberOfComponents(), nextra );
  ActionWithVessel* vval=dynamic_cast<ActionWithVessel*>( myOutputAction );
  for(unsigned i=0;i<nextra;++i){
      vval->bridgeVariable=i; getAction()->calculate();
      for(int j=0;j<myOutputValues->getNumberOfComponents();++j) tmpder(j,i) = myOutputValues->getOutputQuantity(j);
  }
  vval->bridgeVariable=nextra; getAction()->calculate(); 
  plumed_assert( inum==mynumerical_values.size() ); inum=0;  // Reset inum now that we have finished calling calculate
  std::vector<double> base( myOutputValues->getNumberOfComponents() );
  for(int j=0;j<myOutputValues->getNumberOfComponents();++j) base[j] = myOutputValues->getOutputQuantity(j);

  const double delta=sqrt(epsilon);
  ActionAtomistic* aa=dynamic_cast<ActionAtomistic*>( getAction() );
  unsigned nvals=myOutputValues->getNumberOfComponents();
  for(unsigned j=0;j<nvals;++j) ( myOutputValues->copyOutput(j) )->clearDerivatives();   

  if( aa ){
      ActionWithArguments* aarg=dynamic_cast<ActionWithArguments*>( getAction() );
      plumed_assert( !aarg ); Tensor box=aa->getBox(); 
      unsigned natoms=aa->getNumberOfAtoms();
      for(unsigned j=0;j<nvals;++j){
          double ref=( myOutputValues->copyOutput(j) )->get();
          if( ( myOutputValues->copyOutput(j) )->getNumberOfDerivatives()>0 ){
              for(unsigned i=0;i<3*natoms;++i){
                  double d=( mynumerical_values[i*nvals+j] - ref)/delta;
                  ( myOutputValues->copyOutput(j) )->addDerivative(i,d);
              }
              Tensor virial;
              for(int i=0;i<3;i++) for(int k=0;k<3;k++){
                 virial(i,k)=( mynumerical_values[ nvals*(3*natoms + 3*i + k) + j ]-ref)/delta;
              }
              virial=-matmul(box.transpose(),virial);
              for(int i=0;i<3;i++) for(int k=0;k<3;k++) ( myOutputValues->copyOutput(j) )->addDerivative(3*natoms+3*k+i,virial(k,i));
          }
      }
  } else {
      plumed_merror("not implemented or tested yet");
//      unsigned nder=myOutputAction->getNumberOfDerivatives();
//      for(unsigned j=0;j<nvals;++j){
//          double ref=( myOutputValues->copyOutput(j) )->get();
//              for(unsigned i=0;i<nder;++i){
//                  double d=( mynumerical_values[i*nvals+j] - ref)/delta;
//                  ( myOutputValues->copyOutput(j) )->addDerivative(i,d);
//              }
//          }
//      }
  }
  // Add the derivatives wrt to the local quantities we are working with
  for(unsigned j=0;j<nvals;++j){
     unsigned k=0;
     for(unsigned i=getAction()->getNumberOfDerivatives();i<myOutputAction->getNumberOfDerivatives();++i){
        ( myOutputValues->copyOutput(j) )->addDerivative( i, (tmpder(j,k)-base[j])/sqrt(epsilon) ); k++;
     }
  }
}
コード例 #7
0
void InterpolateCubic::set_table( const std::vector<Value>& ff ){
  plumed_assert( getNumberOfSplinePoints()==ff.size() ); 
  plumed_assert( ff[0].getNumberOfDerivatives()==1 );

  double d1, norm; unsigned pij;
  for(unsigned i=0;i<np[0]-1;++i){
      d1 = getPointSpacing( 0, i );   
      norm=(d1*d1)/6.0; pij=i*4;
      clist[pij]=ff[i].get(); pij++;
      clist[pij]=ff[i+1].get(); pij++;
      clist[pij]=ff[i].getDerivative(0)*norm; pij++;
      clist[pij]=ff[i+1].getDerivative(0)*norm;   
  }
}
コード例 #8
0
ファイル: LinkCells.cpp プロジェクト: GaganDhanoa/plumed2
void LinkCells::retrieveNeighboringAtoms( const Vector& pos, unsigned& natomsper, std::vector<unsigned>& atoms ) const {
  plumed_assert( natomsper==1 || natomsper==2 );  // This is really a bug. If you are trying to reuse this ask GAT for help
  std::vector<unsigned> celn( findMyCell( pos ) );

  for(int nx=LINKC_MIN(ncells[0]);nx<LINKC_MAX(ncells[0]);++nx){
     int xval = celn[0] + nx;  
     xval=LINKC_PBC(xval,ncells[0])*nstride[0]; 
     for(int ny=LINKC_MIN(ncells[1]);ny<LINKC_MAX(ncells[1]);++ny){
         int yval = celn[1] + ny;  
         yval=LINKC_PBC(yval,ncells[1])*nstride[1]; 
         for(int nz=LINKC_MIN(ncells[2]);nz<LINKC_MAX(ncells[2]);++nz){
             int zval = celn[2] + nz;
             zval=LINKC_PBC(zval,ncells[2])*nstride[2]; 

             unsigned mybox=xval+yval+zval;
             for(unsigned k=0;k<lcell_tots[mybox];++k){
                 unsigned myatom = lcell_lists[lcell_starts[mybox]+k];
                 if( myatom!=atoms[0] ){  // Ideally would provide an option to not do this
                     atoms[natomsper]=myatom;
                     natomsper++;
                 } 
             }
         }
     }
  }
}
コード例 #9
0
MultiReferenceBase::MultiReferenceBase( const std::string& type, const bool& checksoff ):
  wasSet(false),
  skipchecks(checksoff),
  mtype(type)
{
  if(checksoff) plumed_assert( mtype.length()==0 );
}
コード例 #10
0
ManyRestraintsBase::ManyRestraintsBase(const ActionOptions& ao):
    Action(ao),
    ActionWithValue(ao),
    ActionPilot(ao),
    ActionWithVessel(ao),
    ActionWithInputVessel(ao)
{
    // Read in the vessel we are action on
    readArgument("bridge");
    aves=dynamic_cast<ActionWithVessel*>( getDependencies()[0] );

    plumed_assert( getDependencies().size()==1 && aves );
    log.printf("  adding restraints on variables calculated by %s action with label %s\n",
               aves->getName().c_str(),aves->getLabel().c_str());

    // Add a task list in order to avoid problems
    for(unsigned i=0; i<aves->getFullNumberOfTasks(); ++i) addTaskToList( aves->getTaskCode(i) );
    // And turn on the derivatives (note problems here because of ActionWithValue)
    turnOnDerivatives();
    needsDerivatives();

    // Now create the vessel
    std::string fake_input="LABEL=bias";
    addVessel( "SUM", fake_input, 0 );
    readVesselKeywords();
}
コード例 #11
0
ファイル: OFile.cpp プロジェクト: BingqingCheng/plumed2
OFile& OFile::rewind() {
// we use here "hard" rewind, which means close/reopen
// the reason is that normal rewind does not work when in append mode
// moreover, we can take a backup of the file
  plumed_assert(fp);
  clearFields();
  if(gzfp) {
#ifdef __PLUMED_HAS_ZLIB
    gzclose((gzFile)gzfp);
#endif
  } else fclose(fp);
  if(!comm || comm->Get_rank()==0) {
    std::string fname=this->path;
    size_t found=fname.find_last_of("/\\");
    std::string directory=fname.substr(0,found+1);
    std::string file=fname.substr(found+1);
    std::string backup=directory+backstring +".last."+file;
    int check=rename(fname.c_str(),backup.c_str());
    plumed_massert(check==0,"renaming "+fname+" into "+backup+" failed for reason: "+strerror(errno));
  }
  if(gzfp) {
#ifdef __PLUMED_HAS_ZLIB
    gzfp=(void*)gzopen(const_cast<char*>(this->path.c_str()),"w9");
#endif
  } else fp=std::fopen(const_cast<char*>(path.c_str()),"w");
  return *this;
}
コード例 #12
0
ファイル: Stopwatch.cpp プロジェクト: JFDama/plumed2
void Stopwatch::Watch::pause() {
  plumed_assert(running>0);
  running--;
  if(running!=0) return;
  auto t=std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now()-lastStart);
  lap+=t.count();
}
コード例 #13
0
void ActionWithVessel::readVesselKeywords(){
  // Set maxderivatives if it is too big
  if( maxderivatives>getNumberOfDerivatives() ) maxderivatives=getNumberOfDerivatives();

  // Loop over all keywords find the vessels and create appropriate functions
  for(unsigned i=0;i<keywords.size();++i){
      std::string thiskey,input; thiskey=keywords.getKeyword(i);
      // Check if this is a key for a vessel
      if( vesselRegister().check(thiskey) ){
          plumed_assert( keywords.style(thiskey,"vessel") );
          bool dothis=false; parseFlag(thiskey,dothis);
          if(dothis) addVessel( thiskey, input );

          parse(thiskey,input);
          if(input.size()!=0){ 
                addVessel( thiskey, input );
          } else {
             for(unsigned i=1;;++i){
                if( !parseNumbered(thiskey,i,input) ) break;
                std::string ss; Tools::convert(i,ss);
                addVessel( thiskey, input, i ); 
                input.clear();
             } 
          }
      }
  }

  // Make sure all vessels have had been resized at start
  if( functions.size()>0 ) resizeFunctions();
}
コード例 #14
0
ファイル: Action.cpp プロジェクト: BingqingCheng/plumed2
void Action::registerKeywords( Keywords& keys ) {
  plumed_assert( keys.size()==0 );
  keys.add( "hidden", "LABEL", "a label for the action so that its output can be referenced in the input to other actions.  Actions with scalar output are referenced using their label only.  Actions with vector output must have a separate label for every component.  Individual componets are then refered to using label.component" );
  keys.reserve("optional","UPDATE_FROM","Only update this action from this time");
  keys.reserve("optional","UPDATE_UNTIL","Only update this action until this time");
  keys.reserve("optional","RESTART","allows per-action setting of restart (YES/NO/AUTO)");
}
コード例 #15
0
ファイル: MultiColvarBase.cpp プロジェクト: whitead/plumed2
void MultiColvarBase::activateIndexes( const unsigned& istart, const unsigned& number, const std::vector<unsigned>& indexes ){
  plumed_assert( number>0 );
  for(unsigned i=0;i<number-9;i+=3){
      plumed_dbg_assert( indexes[istart+i]%3==0 ); unsigned iatom=indexes[istart+i]/3; 
      atoms_with_derivatives.activate( iatom ); 
  }
}
コード例 #16
0
void ClusterWithSurface::retrieveAtomsInCluster( const unsigned& clust, std::vector<unsigned>& myatoms ) const {
  std::vector<unsigned> tmpat; myclusters->retrieveAtomsInCluster( clust, tmpat );

  // Prevent double counting
  std::vector<bool> incluster( getNumberOfNodes(), false );
  for(unsigned i=0;i<tmpat.size();++i) incluster[tmpat[i]]=true;

  // Find the atoms in the the clusters
  std::vector<bool> surface_atom( getNumberOfNodes(), false ); 
  for(unsigned i=0;i<tmpat.size();++i){
      for(unsigned j=0;j<getNumberOfNodes();++j){
         if( incluster[j] ) continue;
         double dist2=getSeparation( getPosition(tmpat[i]), getPosition(j) ).modulo2();
         if( dist2<rcut_surf2 ){ surface_atom[j]=true; }
      }
  }
  unsigned nsurf_at=0; 
  for(unsigned j=0;j<getNumberOfNodes();++j){
     if( surface_atom[j] ) nsurf_at++; 
  }
  myatoms.resize( nsurf_at + tmpat.size() );
  for(unsigned i=0;i<tmpat.size();++i) myatoms[i]=tmpat[i];
  unsigned nn=tmpat.size();
  for(unsigned j=0;j<getNumberOfNodes();++j){
      if( surface_atom[j] ){ myatoms[nn]=j; nn++; }
  }
  plumed_assert( nn==myatoms.size() );
}
コード例 #17
0
ファイル: HistogramBead.cpp プロジェクト: JFDama/plumed2
void HistogramBead::generateBins( const std::string& params, std::vector<std::string>& bins ) {
  std::vector<std::string> data=Tools::getWords(params);
  plumed_massert(data.size()>=1,"There is no input for this keyword");

  std::string name=data[0];

  unsigned nbins; std::vector<double> range(2); std::string smear;
  bool found_nb=Tools::parse(data,"NBINS",nbins);
  plumed_massert(found_nb,"Number of bins in histogram not found");
  bool found_r=Tools::parse(data,"LOWER",range[0]);
  plumed_massert(found_r,"Lower bound for histogram not specified");
  found_r=Tools::parse(data,"UPPER",range[1]);
  plumed_massert(found_r,"Upper bound for histogram not specified");
  plumed_massert(range[0]<range[1],"Range specification is dubious");
  bool found_b=Tools::parse(data,"SMEAR",smear);
  if(!found_b) { Tools::convert(0.5,smear); }

  std::string lb,ub; double delr = ( range[1]-range[0] ) / static_cast<double>( nbins );
  for(unsigned i=0; i<nbins; ++i) {
    Tools::convert( range[0]+i*delr, lb );
    Tools::convert( range[0]+(i+1)*delr, ub );
    bins.push_back( name + " " +  "LOWER=" + lb + " " + "UPPER=" + ub + " " + "SMEAR=" + smear );
  }
  plumed_assert(bins.size()==nbins);
}
コード例 #18
0
void ReferenceArguments::setReferenceArguments( const std::vector<double>& arg_vals, const std::vector<double>& sigma ) {
  moveReferenceArguments( arg_vals );

  if( hasmetric ) {
    unsigned k=0;
    for(unsigned i=0; i<reference_args.size(); ++i) {
      for(unsigned j=i; j<reference_args.size(); ++j) {
        metric(i,j)=metric(j,i)=sigma[k]; k++;
      }
    }
    plumed_assert( k==sigma.size() );
  } else {
    plumed_assert( reference_args.size()==sigma.size() );
    for(unsigned i=0; i<reference_args.size(); ++i) weights[i]=sigma[i];
  }
}
コード例 #19
0
ファイル: OFile.cpp プロジェクト: BingqingCheng/plumed2
OFile& OFile::open(const std::string&path) {
  plumed_assert(!cloned);
  eof=false;
  err=false;
  fp=NULL;
  gzfp=NULL;
  this->path=path;
  this->path=appendSuffix(path,getSuffix());
  if(checkRestart()) {
    fp=std::fopen(const_cast<char*>(this->path.c_str()),"a");
    mode="a";
    if(Tools::extension(this->path)=="gz") {
#ifdef __PLUMED_HAS_ZLIB
      gzfp=(void*)gzopen(const_cast<char*>(this->path.c_str()),"a9");
#else
      plumed_merror("file " + getPath() + ": trying to use a gz file without zlib being linked");
#endif
    }
  } else {
    backupFile( backstring, this->path );
    if(comm)comm->Barrier();
    fp=std::fopen(const_cast<char*>(this->path.c_str()),"w");
    mode="w";
    if(Tools::extension(this->path)=="gz") {
#ifdef __PLUMED_HAS_ZLIB
      gzfp=(void*)gzopen(const_cast<char*>(this->path.c_str()),"w9");
#else
      plumed_merror("file " + getPath() + ": trying to use a gz file without zlib being linked");
#endif
    }
  }
  if(plumed) plumed->insertFile(*this);
  return *this;
}
コード例 #20
0
void MultiReferenceBase::getAtomAndArgumentRequirements( std::vector<AtomNumber>& atoms, std::vector<std::string>& args ) {
  plumed_assert( atoms.size()==0 && args.size()==0 );
  for(unsigned i=0; i<frames.size(); ++i) {
    frames[i]->getAtomRequests( atoms );
    frames[i]->getArgumentRequests( args );
  }
}
コード例 #21
0
StoreCentralAtomsVessel::StoreCentralAtomsVessel( const vesselbase::VesselOptions& da ):
StoreDataVessel(da),
tmpdf(3)
{
  mycolv=dynamic_cast<MultiColvarBase*>( getAction() );
  plumed_assert( mycolv ); completeSetup( mycolv->getCentralAtomElementIndex(), 3 );
}
コード例 #22
0
ファイル: TargetDist.cpp プロジェクト: BingqingCheng/plumed2
void TargetDist::read( const std::vector<double>& targ, std::vector<Value*> ar ) {
  plumed_assert( targ.size()==ar.size() );

  target.resize( ar.size() ); args.resize( ar.size() );
  log.printf("  distance from this point in cv space : ");
  for(unsigned i=0; i<target.size(); ++i) { log.printf("%f ", targ[i]); target[i]=targ[i]; args[i]=ar[i]; }
  log.printf("\n");
}
コード例 #23
0
ファイル: MDAtoms.cpp プロジェクト: apoma/plumed2
void MDAtomsTyped<T>::setp(void*pp){
  T*p=static_cast<T*>(pp);
  plumed_assert(stride==0 || stride==3);
  px=p;
  py=p+1;
  pz=p+2;
  stride=3;
}
コード例 #24
0
ファイル: MDAtoms.cpp プロジェクト: apoma/plumed2
void MDAtomsTyped<T>::setf(void*ff){
  T*f=static_cast<T*>(ff);
  plumed_assert(stride==0 || stride==3);
  fx=f;
  fy=f+1;
  fz=f+2;
  stride=3;
}
コード例 #25
0
ファイル: MDAtoms.cpp プロジェクト: apoma/plumed2
void MDAtomsTyped<T>::setf(void*ff,int i){
  T*f=static_cast<T*>(ff);
  plumed_assert(stride==0 || stride==1);
  if(i==0)fx=f;
  if(i==1)fy=f;
  if(i==2)fz=f;
  stride=1;
}
コード例 #26
0
void MultiColvarBase::setAtomsForCentralAtom( const std::vector<bool>& catom_ind ){
  unsigned nat=0; plumed_assert( catom_ind.size()==ablocks.size() );
  for(unsigned i=0;i<catom_ind.size();++i){
      use_for_central_atom[i]=catom_ind[i]; 
      if( use_for_central_atom[i] ) nat++;
  }
  plumed_dbg_assert( nat>0 ); numberForCentralAtom = 1.0 / static_cast<double>( nat );
}
コード例 #27
0
ファイル: CLTool.cpp プロジェクト: edoardob90/plumed2
void CLTool::parseFlag( const std::string&key, bool&t ){
  plumed_massert(keywords.exists(key),"keyword " + key + " has not been registered");
  plumed_massert(keywords.style(key,"flag"),"keyword " + key + " has not been registered as a flag");
  plumed_assert(inputData.count(key)>0); 
  if( inputData[key]=="true") t=true;
  else if( inputData[key]=="false") t=false;
  else plumed_error();
}
コード例 #28
0
ファイル: LinkCells.cpp プロジェクト: GaganDhanoa/plumed2
std::vector<unsigned> LinkCells::findMyCell( const Vector& pos ) const {
  Vector fpos=mypbc.realToScaled( pos ); std::vector<unsigned> celn(3);
  for(unsigned j=0;j<3;++j){
     celn[j] = std::floor( ( Tools::pbc(fpos[j]) + 0.5 ) * ncells[j] );
     plumed_assert( celn[j]>=0 && celn[j]<ncells[j] ); // Check that atom is in box  
  }
  return celn;
}
コード例 #29
0
ファイル: MDAtoms.cpp プロジェクト: apoma/plumed2
void MDAtomsTyped<T>::setp(void*pp,int i){
  T*p=static_cast<T*>(pp);
  plumed_assert(stride==0 || stride==1);
  if(i==0)px=p;
  if(i==1)py=p;
  if(i==2)pz=p;
  stride=1;
}
コード例 #30
0
ファイル: Direction.cpp プロジェクト: GaganDhanoa/plumed2
double Direction::calc( const std::vector<Vector>& pos, const Pbc& pbc, const std::vector<Value*>& vals, const std::vector<double>& args, 
                        ReferenceValuePack& myder, const bool& squared ) const {
  plumed_assert( squared );
  for(unsigned i=0;i<getNumberOfReferenceArguments();++i) myder.addArgumentDerivatives( i, -2.*getReferenceArgument(i) );
  for(unsigned i=0;i<getNumberOfAtoms();++i) myder.getAtomsDisplacementVector()[i]=getReferencePosition(i);
  
  return 0.0;
}