void FPairTensor::setup()
{
  FPairArbitraryWF::setup();

  ColourPair *m_cp = M_MANAGER->cp(M_MANAGER->getColour(m_species.first), M_MANAGER->getColour(m_species.second));

  m_pairFactor.setReturnType(Variant::TENSOR);
//   m_pairFactor.setColourPair(m_cp);
  m_1stparticleFactor.setReturnType(Variant::TENSOR);
  m_2ndparticleFactor.setReturnType(Variant::TENSOR);


/*  if (m_pairFactor.isNull()) {
  throw gError("FPairTensor::setup", "Please specify a function for 'pairFactor'.");
}*/

  DataFormat::attribute_t firstAttr =
      Particle::s_tag_format[m_cp->firstColour()].attrByName(m_tensor_name);

  DataFormat::attribute_t secondAttr =
      Particle::s_tag_format[m_cp->secondColour()].attrByName(m_tensor_name);

  if(firstAttr.datatype != DataFormat::TENSOR)
    throw gError("FPairScalar::setup", "the symbol " + m_tensor_name +
        " is registerd as a non-tensor for species " +
            m_cp->manager()->species(m_cp->firstColour()));

  if(secondAttr.datatype != DataFormat::TENSOR)
    throw gError("FPairScalar::setup", "the symbol " + m_tensor_name +
        " is registerd as a non-tensor for species " +
            m_cp->manager()->species(m_cp->secondColour()));

  // FIXME: This is general for each FPairArbitrary except for FPairVels. That's why it's still here  => refine hierarchy or remove FPairVels
  for(size_t i = 0; i < FORCE_HIST_SIZE; ++i)
  {
    m_force_offset[i].first =
        Particle::s_tag_format[m_cp->firstColour()].attrByName(string("force_"
        + m_tensor_name + "_" + ObjToString(i))).offset;
    m_force_offset[i].second =
        Particle::s_tag_format[m_cp->secondColour()].attrByName(string("force_"
        + m_tensor_name + "_" + ObjToString(i))).offset;
  }

// Setting the colours this force works on
  size_t col1 = M_MANAGER->getColour(m_species.first);
  size_t col2 = M_MANAGER->getColour(m_species.second);
  ColourPair *cp = M_MANAGER->cp(col1, col2);

  if ((col1 == cp->secondColour()) && (col2 == cp->firstColour())) {
    size_t dummy = col1;
    col1 = col2;
    col2 = dummy;
  }
  else if ((col1 == cp->firstColour()) && (col2 == cp->secondColour())) {
//    MSG_DEBUG("FPairVels::setup", "Force colours same order as ColourPair's colours");
  }
  else {
    throw gError("FPairTensor::setup", "No ColourPair for these colours. Contact the programmer.");
  }
}
Exemple #2
0
void FPairVels::setForceSlots(Integrator* intr, int thread_no) {
  size_t col1 = M_MANAGER->getColour(m_species.first);
  size_t col2 = M_MANAGER->getColour(m_species.second);
  string dof = "vel_pos";
  ColourPair *cp = M_MANAGER->cp(col1, col2);

  if (col1 == intr->colour()) {
    if (dof == intr->dofIntegr()) {
      if (col1 == cp->firstColour()) {
        intr->merge() = true;
        m_offsetToVec[thread_no].first = intr->offsetToVec()[thread_no];
        m_posInVec.first = intr->posInVec();
      }
      else if (col1 == cp->secondColour()) {
        intr->merge() = true;
        m_offsetToVec[thread_no].second = intr->offsetToVec()[thread_no];
        m_posInVec.second = intr->posInVec();
      }
      else {
        throw gError("FPairVels::setForceSlots", "No match for this Force's colours for the ColourPair. Contact the programmer.");
      }
    }
  }
  if (col2 == intr->colour()) {
    if (dof == intr->dofIntegr()) {
      if (col2 == cp->secondColour()) {
        intr->merge() = true;
        m_offsetToVec[thread_no].second = intr->offsetToVec()[thread_no];
        m_posInVec.second = intr->posInVec();
      }
      else if (col2 == cp->firstColour()) {
        intr->merge() = true;
        m_offsetToVec[thread_no].first = intr->offsetToVec()[thread_no];
        m_posInVec.first = intr->posInVec();        
      }
      else {
        throw gError("FPairVels::setForceSlots", "No match for this Force's colours for the ColourPair. Contact the programmer.");
      }
    }
  }
}
Exemple #3
0
void FPairVels::setup()
{
  FPairArbitrary::setup();

  m_pairFactor.setReturnType(Variant::VECTOR);
  m_1stparticleFactor.setReturnType(Variant::VECTOR);
  m_2ndparticleFactor.setReturnType(Variant::VECTOR);

// Setting the colours this force works on
  size_t col1 = M_MANAGER->getColour(m_species.first);
  size_t col2 = M_MANAGER->getColour(m_species.second);
  ColourPair *cp = M_MANAGER->cp(col1, col2);

  if ((col1 == cp->secondColour()) && (col2 == cp->firstColour())) {
    size_t dummy = col1;
    col1 = col2;
    col2 = dummy;
  }
  else if ((col1 == cp->firstColour()) && (col2 == cp->secondColour())) {
//    MSG_DEBUG("FPairVels::setup", "Force colours same order as ColourPair's colours");
  }
  else {
    throw gError("FPairVels::setup", "No ColourPair for these colours. Contact the programmer.");
  }

  if(m_cutoff <= 0)
    throw gError("FPairVels::setup", "Please define a cutoff >0");

  cp->setCutoff(m_cutoff);

}
void BondedPairParticleCalc::setup()
{
   if(m_symmetry != -1 && m_symmetry != 1)
     throw gError("BondedPairParticleCalc::setup", "For module " + name() + ": Define attribute 'symmetry'! It may only be \"-1\" (antisymmetry) or \"1\" (symmetry). Currently it is " + ObjToString(m_symmetry) + "!");

  if(m_listName == "undefined")
    throw gError("BondedPairParticleCalc::setup", "Attribute 'listName' is undefined!");
       
  if(m_phaseUser != 0 && m_phaseUser != 1 && m_phaseUser != 2)
    throw gError("BondedPairParticleCalc::setup", ": Attribute 'stage' is " + ObjToString(m_phaseUser) + ", which is none of the allowed values \"0\", \"1\", \"2\".");
   
  if(m_species.first == "undefined")
    throw gError("BondedPairParticleCalc::setup", "For module " + name() + ": Attribute 'species1' has value \"undefined\"."); 
  if(m_species.second == "undefined")
    throw gError("BondedPairParticleCalc::setup", "For module " + name() + ": Attribute 'species2' has value \"undefined\"."); 
  
  ColourPair* cp = M_MANAGER->cp(M_MANAGER->getColour(m_species.first), M_MANAGER->getColour(m_species.second)/*m_species*/);
  
  
  // next lines are just necessary for non-bonded pairs, so not here!
  //      cp->setNeedPairs(true);
  //   cp->setCutoff(m_cutoff);
  
  if(m_overwrite)
    {
      try
	{
	  m_slots.first = Particle::s_tag_format[cp->firstColour()].indexOf(m_symbolName, m_datatype);
	  m_slots.first = Particle::s_tag_format[cp->firstColour()].offsetByIndex(m_slots.first);
	}
      catch(gError& err)
	{
	  throw gError("BondedPairParticleCalc::setup", ": search for symbol for species '" + M_MANAGER->species(cp->firstColour()) + " failed, but need one because 'overwrite = \"yes\"'. The message was " + err.message()); 
	}
      try
	{
	  m_slots.second = Particle::s_tag_format[cp->secondColour()].indexOf(m_symbolName, m_datatype);
	  m_slots.second = Particle::s_tag_format[cp->secondColour()].offsetByIndex(m_slots.second);
	}
      catch(gError& err)
	{
	  throw gError("BondedPairParticleCalc::setup", ": search for symbol for species '" + M_MANAGER->species(cp->secondColour()) + " failed, but need one because 'overwrite = \"yes\"'. The message was " + err.message()); 
	}      
    }
  else // m_overwrite = false
    {
      if(Particle::s_tag_format[cp->firstColour()].attrExists(m_symbolName)) 
        throw gError("BondedPairParticleCalc::setup", ": Symbol " + m_symbolName + " is already existing for species '" + M_MANAGER->species(cp->firstColour()) + "'. Second definition is not allowed for overwrite = \"no\"");
      
      if(Particle::s_tag_format[cp->secondColour()].attrExists(m_symbolName))
        throw gError("BondedPairParticleCalc::setup", ": Symbol " + m_symbolName + " is already existing for species '" + M_MANAGER->species(cp->secondColour()) + "'. Second definition is not allowed for overwrite = \"no\"");
      
      // see CONVENTION5 for rule about persistencies
      m_slots.first = Particle::s_tag_format[cp->firstColour()].addAttribute(m_symbolName, m_datatype, /*persist.first*/false, m_symbolName).offset;
      
      if(cp->firstColour() != cp->secondColour())
	{
	  // see CONVENTION5 for rule about persistencies
	  m_slots.second = Particle::s_tag_format[cp->secondColour()].addAttribute(m_symbolName, m_datatype, /*persist.second*/false, m_symbolName).offset;
	}
      else m_slots.second = m_slots.first;
    } // end of else-case where m_overwrite = false
  
  MSG_DEBUG("BondedPairParticleCalc::setup", ": registering " << this->name() << ".");
  
  if(m_phaseUser == 0)    
    cp->registerBondedCalc_0(this);
  else if(m_phaseUser == 1)    
    cp->registerBondedCalc(this);
  else // so it is 2
    {
      ValCalculator* vc = copyMySelf() /*new BondedPairParticleCalc(*this)*/;

      copyMembersTo(vc);
      
      MSG_DEBUG("BondedPairParticleCalc::setup", ": registering copy of " << this->name() << ", CP = (" << cp->firstColour() << ", " << cp->secondColour() << ")");    
      
      cp->registerBondedCalc(vc);
      cp->registerBondedCalc_0(this);
    }

}