Beispiel #1
0
void
ISoftCore::checkOverlaps(const Particle& part1, const Particle& part2) const
{
  Vector  rij = part1.getPosition() - part2.getPosition();
  Sim->dynamics.BCs().applyBC(rij);
  double r2 = rij.nrm2();

  double d2 = (_diameter->getProperty(part1.getID())
	       + _diameter->getProperty(part2.getID())) * 0.5;
  d2 *= d2;

  if (isCaptured(part1, part2))
    {
      if (r2 > d2)
	derr << "Possible escaped captured pair in diagnostics\n ID1=" << part1.getID() 
	     << ", ID2=" << part2.getID() << "\nR_ij^2=" 
	     << r2 / pow(Sim->dynamics.units().unitLength(),2)
	     << "\nd^2=" 
	     << d2 / pow(Sim->dynamics.units().unitLength(),2) << std::endl;
    }
  else 
    if (r2 < d2)
      derr << "Possible missed captured pair in diagnostics\n ID1=" << part1.getID() 
	   << ", ID2=" << part2.getID() << "\nR_ij^2=" 
	   << r2 / pow(Sim->dynamics.units().unitLength(),2)
	   << "\nd^2=" 
	   << d2 / pow(Sim->dynamics.units().unitLength(),2) << std::endl;
}
Beispiel #2
0
  double 
  ISquareWell::getInternalEnergy(const Particle& p1, const Particle& p2) const
  {
    return - 0.5 * (_wellDepth->getProperty(p1.getID())
		    +_wellDepth->getProperty(p2.getID()))
      * isCaptured(p1, p2);
  }
Beispiel #3
0
  Event
  IDSMC::getEvent(const Particle &p1, const Particle &p2) const
  {
#ifdef DYNAMO_DEBUG
    if (!Sim->dynamics->isUpToDate(p1))
      M_throw() << "Particle 1 is not up to date";
  
    if (!Sim->dynamics->isUpToDate(p2))
      M_throw() << "Particle 2 is not up to date";

    if (p1 == p2)
      M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif 
    
    const double l = _length->getProperty(p1, p2);
    if (isCaptured(p1, p2))
      {
	double dt = Sim->dynamics->SphereSphereOutRoot(p1, p2, l);
	return Event(p1, dt, INTERACTION, NBHOOD_OUT, ID, p2);
      }
    else 
      {
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, l);
	if (dt != std::numeric_limits<float>::infinity())
	  return Event(p1, dt, INTERACTION, NBHOOD_IN, ID, p2);
      }
    
    return Event(p1, std::numeric_limits<float>::infinity(), INTERACTION, NONE, ID, p2);
  }
Beispiel #4
0
 double 
 ISWSequence::getInternalEnergy(const Particle& p1, const Particle& p2) const
 {
   return -alphabet[sequence[p1.getID() % sequence.size()]][sequence[p2.getID() % sequence.size()]]
     * 0.5 * (_unitEnergy->getProperty(p1.getID()) + _unitEnergy->getProperty(p2.getID()))
     * isCaptured(p1, p2);
 }
Beispiel #5
0
  PairEventData
  IThinThread::runEvent(Particle& p1, Particle& p2, Event iEvent)
  {
    ++Sim->eventCount;

    const double d = _diameter->getProperty(p1, p2);
    const double d2 = d * d;
    const double e = _e->getProperty(p1, p2);
    const double l = _lambda->getProperty(p1, p2);
    const double ld2 = d * l * d * l;
    const double wd = _wellDepth->getProperty(p1, p2);

    switch (iEvent._type)
      {
      case CORE:
	{
	  PairEventData retVal = Sim->dynamics->SmoothSpheresColl(iEvent, e, d2, CORE);
	  if (!isCaptured(p1, p2))
	    {
	      retVal.setType(STEP_IN);
	      ICapture::add(p1, p2);
	    }
	  return retVal;
	}
      case STEP_OUT:
	{
	  PairEventData retVal = Sim->dynamics->SphereWellEvent(iEvent, -wd, ld2, 0);
	  if (retVal.getType() != BOUNCE) ICapture::remove(p1, p2);
	  return retVal;
	}
      default:
	M_throw() << "Unknown collision type";
      }
  }
Beispiel #6
0
  bool
  ILines::validateState(const Particle& p1, const Particle& p2, bool textoutput) const
  {
    double l = (_length->getProperty(p1.getID())
		+ _length->getProperty(p2.getID())) * 0.5;

    if (isCaptured(p1, p2))
      {
	if (!Sim->dynamics->sphereOverlap(p1, p2, l))
	  {
	    if (textoutput)
	      derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		   << " are registered as being closer than " << l / Sim->units.unitLength()
		   << " but they are at a distance of " 
		   << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		   << std::endl;

	    return true;
	  }
      }
    else
      if (Sim->dynamics->sphereOverlap(p1, p2, l))
	{
	  if (textoutput)
	    derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		 << " are not registered as being closer than " << l / Sim->units.unitLength()
		 << " but they are at a distance of " 
		 << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		 << std::endl;
	  return true;
	}

    return false;
  }
std::string
pcl::io::depth_sense::DepthSenseDeviceManager::captureDevice (DepthSenseGrabberImpl* grabber, size_t index)
{
  boost::mutex::scoped_lock lock (mutex_);
  if (index >= context_.getDevices ().size ())
    THROW_IO_EXCEPTION ("device with index %i is not connected", index + 1);
  if (isCaptured (context_.getDevices ().at (index).getSerialNumber ()))
    THROW_IO_EXCEPTION ("device with index %i is captured by another grabber", index);
  return (captureDevice (grabber, context_.getDevices ().at (index)));
}
Beispiel #8
0
 void ColorNode::toggleSelect()
 {
     m_flags ^= IsSelectedMask;
     
     setFrame(
              isSelected() ?
              ColorNodeFrames::get()->selected_frame :
              isCaptured() ?
              ColorNodeFrames::get()->captured_frame :
              ColorNodeFrames::get()->deselected_frame );
 }
Beispiel #9
0
  IntEvent 
  ISWSequence::getEvent(const Particle &p1, 
			const Particle &p2) const 
  {    
#ifdef DYNAMO_DEBUG
    if (!Sim->dynamics->isUpToDate(p1))
      M_throw() << "Particle 1 is not up to date";
  
    if (!Sim->dynamics->isUpToDate(p2))
      M_throw() << "Particle 2 is not up to date";

    if (p1 == p2)
      M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif 

    double d = (_diameter->getProperty(p1.getID())
		+ _diameter->getProperty(p2.getID())) * 0.5;

    double l = (_lambda->getProperty(p1.getID())
		+ _lambda->getProperty(p2.getID())) * 0.5;

    const double pairenergy = alphabet[sequence[p1.getID() % sequence.size()]][sequence[p2.getID() % sequence.size()]] * _unitEnergy->getMaxValue();

    /* Check if there is no well here at all, and just use a hard core interaction */
    if (pairenergy == 0)
      {
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, d);
	if (dt != HUGE_VAL)
	  return IntEvent(p1, p2, dt, CORE, *this);
	else
	  return IntEvent(p1, p2, HUGE_VAL, NONE, *this);
      }
	
    if (isCaptured(p1, p2))
      {
	IntEvent retval(p1, p2, HUGE_VAL, NONE, *this);
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, d);
	if (dt != HUGE_VAL)
	  retval = IntEvent(p1, p2, dt, CORE, *this);
      
	dt = Sim->dynamics->SphereSphereOutRoot(p1, p2, l * d);
	if (retval.getdt() > dt)
	  retval = IntEvent(p1, p2, dt, STEP_OUT, *this);
	return retval;
      }
    else
      {
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, l * d);
	if (dt != HUGE_VAL)
	  return IntEvent(p1, p2, dt, STEP_IN, *this);
      }
    
    return IntEvent(p1, p2, HUGE_VAL, NONE, *this);
  }
Beispiel #10
0
double 
IStepped::getInternalEnergy(const Particle& p1, const Particle& p2) const
{
  const_cmap_it capstat = getCMap_it(p1,p2);
  if (capstat == captureMap.end())
    return 0;
  else
    return steps[capstat->second - 1].second
      * 0.5 * (_unitEnergy->getProperty(p1.getID())
	       + _unitEnergy->getProperty(p2.getID()))
      * isCaptured(p1, p2);
}
Beispiel #11
0
  void
  ISWSequence::checkOverlaps(const Particle& part1, const Particle& part2) const
  {
    Vector  rij = part1.getPosition() - part2.getPosition();
    Sim->dynamics.BCs().applyBC(rij);
    double r2 = rij.nrm2();

    double d = (_diameter->getProperty(part1.getID())
		+ _diameter->getProperty(part2.getID())) * 0.5;

    double d2 = d * d;

    double l = (_lambda->getProperty(part1.getID())
		+ _lambda->getProperty(part2.getID())) * 0.5;
  
    double ld2 = d * l * d * l;

    if (isCaptured(part1, part2))
      {
	if (r2 < d2)
	  derr << "Possible captured overlap occured in diagnostics\n ID1=" << part1.getID() 
	       << ", ID2=" << part2.getID() << "\nR_ij^2=" 
	       << r2 / pow(Sim->dynamics.units().unitLength(),2)
	       << "\nd^2=" 
	       << d2 / pow(Sim->dynamics.units().unitLength(),2) << std::endl;

	if (r2 > ld2)
	  derr << "Possible escaped captured pair in diagnostics\n ID1=" << part1.getID() 
	       << ", ID2=" << part2.getID() << "\nR_ij^2=" 
	       << r2 / pow(Sim->dynamics.units().unitLength(),2)
	       << "\n(lambda * d)^2=" 
	       << ld2 / pow(Sim->dynamics.units().unitLength(),2) << std::endl;
      }
    else 
      {
	if (r2 < d2)
	  derr << "Particles overlapping cores without even being captured."
	       << "\nProbably a bad initial configuration."
	       << "\n ID1=" 
	       << part1.getID() 
	       << ", ID2=" << part2.getID() << "\nR_ij^2=" 
	       << r2 / pow(Sim->dynamics.units().unitLength(),2)
	       << "\nd^2=" 
	       << d2 / pow(Sim->dynamics.units().unitLength(),2) << std::endl;
	if (r2 < ld2)
	  derr << "Possible missed captured pair in diagnostics\n ID1=" 
	       << part1.getID() 
	       << ", ID2=" << part2.getID() << "\nR_ij^2=" 
	       << r2 / pow(Sim->dynamics.units().unitLength(),2)
	       << "\n(lambda * d)^2=" 
	       << ld2 / pow(Sim->dynamics.units().unitLength(),2) << std::endl;
      }
  }
Beispiel #12
0
std::string
pcl::io::depth_sense::DepthSenseDeviceManager::captureDevice (DepthSenseGrabberImpl* grabber)
{
  boost::mutex::scoped_lock lock (mutex_);
  std::vector<DepthSense::Device> devices = context_.getDevices ();
  if (devices.size () == 0)
    THROW_IO_EXCEPTION ("no connected devices");
  for (size_t i = 0; i < devices.size (); ++i)
    if (!isCaptured (devices[i].getSerialNumber ()))
      return (captureDevice (grabber, devices[i]));
  THROW_IO_EXCEPTION ("all connected devices are captured by other grabbers");
  return ("");  // never reached, needed just to silence -Wreturn-type warning
}
Beispiel #13
0
  void
  IThinThread::runEvent(Particle& p1, Particle& p2, const IntEvent& iEvent)
  {
    ++Sim->eventCount;

    double d = (_diameter->getProperty(p1.getID())
		+ _diameter->getProperty(p2.getID())) * 0.5;
    double d2 = d * d;

    double e = (_e->getProperty(p1.getID())
		+ _e->getProperty(p2.getID())) * 0.5;

    double l = (_lambda->getProperty(p1.getID())
		+ _lambda->getProperty(p2.getID())) * 0.5;
    double ld2 = d * l * d * l;

    double wd = (_wellDepth->getProperty(p1.getID())
		 + _wellDepth->getProperty(p2.getID())) * 0.5;
    switch (iEvent.getType())
      {
      case CORE:
	{
	  PairEventData retVal(Sim->dynamics->SmoothSpheresColl(iEvent, e, d2, CORE));
	  IntEvent event(iEvent);
	  if (!isCaptured(p1, p2))
	    {
	      event.setType(STEP_IN);
	      retVal.setType(STEP_IN);
	      ICapture::add(p1, p2);
	    }
	  
	  (*Sim->_sigParticleUpdate)(retVal);
	  Sim->ptrScheduler->fullUpdate(p1, p2);
	  for (shared_ptr<OutputPlugin> & Ptr : Sim->outputPlugins)
	    Ptr->eventUpdate(event, retVal);
	  break;
	}
      case STEP_OUT:
	{
	  PairEventData retVal(Sim->dynamics->SphereWellEvent(iEvent, -wd, ld2, 0));
	  if (retVal.getType() != BOUNCE) ICapture::remove(p1, p2);
	  (*Sim->_sigParticleUpdate)(retVal);
	  Sim->ptrScheduler->fullUpdate(p1, p2);
	  for (shared_ptr<OutputPlugin> & Ptr : Sim->outputPlugins)
	    Ptr->eventUpdate(iEvent, retVal);
	  break;
	}
      default:
	M_throw() << "Unknown collision type";
      } 
  }
Beispiel #14
0
SymbolTable* SymbolTable::cloneCapturedNames(VM& vm)
{
    SymbolTable* result = SymbolTable::create(vm);
    
    result->m_parameterCountIncludingThis = m_parameterCountIncludingThis;
    result->m_usesNonStrictEval = m_usesNonStrictEval;
    result->m_captureStart = m_captureStart;
    result->m_captureEnd = m_captureEnd;

    for (auto iter = m_map.begin(), end = m_map.end(); iter != end; ++iter) {
        if (!isCaptured(iter->value.getIndex()))
            continue;
        result->m_map.add(
            iter->key,
            SymbolTableEntry(iter->value.getIndex(), iter->value.getAttributes()));
    }
    
    if (m_slowArguments) {
        result->m_slowArguments = std::make_unique<SlowArgument[]>(parameterCount());
        for (unsigned i = parameterCount(); i--;)
            result->m_slowArguments[i] = m_slowArguments[i];
    }

    if (m_uniqueIDMap && result->m_uniqueIDMap) {

        {
            auto iter = m_uniqueIDMap->begin();
            auto end = m_uniqueIDMap->end();
            for (; iter != end; ++iter)
                result->m_uniqueIDMap->set(iter->key, iter->value);
        }

        {
            auto iter = m_registerToVariableMap->begin();
            auto end = m_registerToVariableMap->end();
            for (; iter != end; ++iter)
                result->m_registerToVariableMap->set(iter->key, iter->value);
        }

        {
            auto iter = m_uniqueTypeSetMap->begin();
            auto end = m_uniqueTypeSetMap->end();
            for (; iter != end; ++iter)
                result->m_uniqueTypeSetMap->set(iter->key, iter->value);
        }
    }

    
    return result;
}
Beispiel #15
0
  bool
  IThinThread::validateState(const Particle& p1, const Particle& p2, bool textoutput) const
  {
    double d = (_diameter->getProperty(p1.getID())
		+ _diameter->getProperty(p2.getID())) * 0.5;
    double l = (_lambda->getProperty(p1.getID())
		+ _lambda->getProperty(p2.getID())) * 0.5;

    if (isCaptured(p1, p2))
      {
	if (!Sim->dynamics->sphereOverlap(p1, p2, l * d))
	  {
	    if (textoutput)
	      derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		   << " registered as being inside the well at " << l * d / Sim->units.unitLength()
		   << " but they are at a distance of " 
		   << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		   << std::endl;
	    
	    return true;
	  }

	if (Sim->dynamics->sphereOverlap(p1, p2, d))
	  {
	    if (textoutput)
	      derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		   << " are inside the well with an inner hard core at " << d / Sim->units.unitLength()
		   << " but they are at a distance of " 
		   << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		   << std::endl;
	    
	    return true;
	  }
      }
    else
      if (Sim->dynamics->sphereOverlap(p1, p2, d))
	{
	  if (textoutput)
	    derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		 << " have entered the core at " << d / Sim->units.unitLength()
		 << " and are at a distance of "
		 << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		 << " AND they've not entered the thin-thread well either."
		 << std::endl;
	  
	  return true;
	}

    return false;
  }
Beispiel #16
0
  IntEvent 
  IDumbbells::getEvent(const Particle &p1,
		       const Particle &p2) const 
  {
#ifdef DYNAMO_DEBUG
    if (!Sim->dynamics.getLiouvillean().isUpToDate(p1))
      M_throw() << "Particle 1 is not up to date";
  
    if (!Sim->dynamics.getLiouvillean().isUpToDate(p2))
      M_throw() << "Particle 2 is not up to date";

    if (p1 == p2)
      M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif 
  
    CPDData colldat(*Sim, p1, p2);
  
    double d = (_diameter->getProperty(p1.getID())
		+ _diameter->getProperty(p2.getID())) * 0.5;

    double l = (_length->getProperty(p1.getID())
		+ _length->getProperty(p2.getID())) * 0.5;
  
    if (isCaptured(p1, p2)) 
      {
	//Run this to determine when the spheres no longer intersect
	Sim->dynamics.getLiouvillean()
	  .SphereSphereOutRoot(colldat, (l + d) * (l + d),
			       p1.testState(Particle::DYNAMIC), p2.testState(Particle::DYNAMIC));

	//colldat.dt has the upper limit of the line collision time
	//Lower limit is right now
	//Test for a line collision
	//Upper limit can be HUGE_VAL!
	if (Sim->dynamics.getLiouvillean().getOffCenterSphereOffCenterSphereCollision
	    (colldat, l, d, p1, p2))
	  return IntEvent(p1, p2, colldat.dt, CORE, *this);
      
	return IntEvent(p1, p2, colldat.dt, WELL_OUT, *this);
      }
  
    if (Sim->dynamics.getLiouvillean()
	.SphereSphereInRoot(colldat, (l + d) * (l + d),
			    p1.testState(Particle::DYNAMIC), 
			    p2.testState(Particle::DYNAMIC))) 
      return IntEvent(p1, p2, colldat.dt, WELL_IN, *this);
  
    return IntEvent(p1, p2, HUGE_VAL, NONE, *this);
  }
Beispiel #17
0
IntEvent
ISoftCore::getEvent(const Particle &p1,
                    const Particle &p2) const
{
#ifdef DYNAMO_DEBUG
    if (!Sim->dynamics.getLiouvillean().isUpToDate(p1))
        M_throw() << "Particle 1 is not up to date";

    if (!Sim->dynamics.getLiouvillean().isUpToDate(p2))
        M_throw() << "Particle 2 is not up to date";

    if (p1 == p2)
        M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif

    double d = (_diameter->getProperty(p1.getID())
                + _diameter->getProperty(p2.getID())) * 0.5;

    if (isCaptured(p1, p2))
    {
        double dt = Sim->dynamics.getLiouvillean().SphereSphereOutRoot(p1, p2, d);
        if (dt != HUGE_VAL)
            return IntEvent(p1, p2, dt, WELL_OUT, *this);
    }
    else
    {
        double dt = Sim->dynamics.getLiouvillean()
                    .SphereSphereInRoot(p1, p2, d);
        if (dt != HUGE_VAL)
        {
#ifdef DYNAMO_OverlapTesting
            if (Sim->dynamics.getLiouvillean().sphereOverlap(p1, p2, d))
                M_throw() << "Overlapping particles found"
                          << ", particle1 " << p1.getID()
                          << ", particle2 " << p2.getID()
                          << "\nOverlap = "
                          << Sim->dynamics.getLiouvillean()
                          .sphereOverlap(p1, p2, d)
                          / Sim->dynamics.units().unitLength();
#endif

            return IntEvent(p1, p2, dt, WELL_IN, *this);
        }
    }

    return IntEvent(p1, p2, HUGE_VAL, NONE, *this);
}
Beispiel #18
0
std::string
pcl::io::depth_sense::DepthSenseDeviceManager::captureDevice (DepthSenseGrabberImpl* grabber, const std::string& sn)
{
  boost::mutex::scoped_lock lock (mutex_);
  std::vector<DepthSense::Device> devices = context_.getDevices ();
  for (size_t i = 0; i < devices.size (); ++i)
  {
    if (devices[i].getSerialNumber () == sn)
    {
      if (isCaptured (sn))
        THROW_IO_EXCEPTION ("device with serial number %s is captured by another grabber", sn.c_str ());
      return (captureDevice (grabber, devices[i]));
    }
  }
  THROW_IO_EXCEPTION ("device with serial number %s is not connected", sn.c_str ());
  return ("");  // never reached, needed just to silence -Wreturn-type warning
}
Beispiel #19
0
  IntEvent 
  ILines::getEvent(const Particle &p1, const Particle &p2) const
  {
#ifdef DYNAMO_DEBUG
    if (!Sim->dynamics->isUpToDate(p1))
      M_throw() << "Particle 1 is not up to date";
  
    if (!Sim->dynamics->isUpToDate(p2))
      M_throw() << "Particle 2 is not up to date";

    if (p1 == p2)
      M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif 
  
    double l = (_length->getProperty(p1.getID())
		+ _length->getProperty(p2.getID())) * 0.5;

    if (isCaptured(p1, p2))
      {
	//Run this to determine when the spheres no longer intersect
	double dt = Sim->dynamics->SphereSphereOutRoot(p1, p2, l);
      
	std::pair<bool, double> colltime = Sim->dynamics->getLineLineCollision(l, p1, p2, dt);

	if (colltime.second == HUGE_VAL)
	  return IntEvent(p1, p2, dt, NBHOOD_OUT, *this);

	//Something happens in the time interval

	if (colltime.first)
	  //Its a collision!
	  return IntEvent(p1, p2, colltime.second, CORE, *this);
	else
	  //Its a virtual event, we need to recalculate in a bit
	  return IntEvent(p1, p2, colltime.second, VIRTUAL, *this);
      }
    else 
      {
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, l);
	if (dt != HUGE_VAL)
	  return IntEvent(p1, p2, dt, NBHOOD_IN, *this);
      }

    return IntEvent(p1, p2, HUGE_VAL, NONE, *this);
  }
Beispiel #20
0
IntEvent 
ISoftCore::getEvent(const Particle &p1, 
		     const Particle &p2) const 
{
#ifdef DYNAMO_DEBUG
  if (!Sim->dynamics.getLiouvillean().isUpToDate(p1))
    M_throw() << "Particle 1 is not up to date";
  
  if (!Sim->dynamics.getLiouvillean().isUpToDate(p2))
    M_throw() << "Particle 2 is not up to date";

  if (p1 == p2)
    M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif 

  CPDData colldat(*Sim, p1, p2);

  double d2 = (_diameter->getProperty(p1.getID())
	       + _diameter->getProperty(p2.getID())) * 0.5;
  d2 *= d2;
    
  if (isCaptured(p1, p2)) 
    {
      if (Sim->dynamics.getLiouvillean()
	  .SphereSphereOutRoot(colldat, d2, 
			       p1.testState(Particle::DYNAMIC), p2.testState(Particle::DYNAMIC)))
	return IntEvent(p1, p2, colldat.dt, WELL_OUT, *this);
    }
  else if (Sim->dynamics.getLiouvillean()
	   .SphereSphereInRoot(colldat, d2,
			       p1.testState(Particle::DYNAMIC), p2.testState(Particle::DYNAMIC))) 
    {
#ifdef DYNAMO_OverlapTesting
      if (Sim->dynamics.getLiouvillean().sphereOverlap(colldat,d2))
	M_throw() << "Overlapping cores (but not registered as captured) particles found in soft core" 
		  << "\nparticle1 " << p1.getID() << ", particle2 " 
		  << p2.getID() << "\nOverlap = " 
		  << (sqrt(colldat.r2) - sqrt(d2)) / Sim->dynamics.units().unitLength();
#endif

      return IntEvent(p1, p2, colldat.dt, WELL_IN, *this);
    }

  return IntEvent(p1, p2, HUGE_VAL, NONE, *this);
}
Beispiel #21
0
  IntEvent
  ISquareWell::getEvent(const Particle &p1, 
			const Particle &p2) const 
  {
#ifdef DYNAMO_DEBUG
    if (!Sim->dynamics->isUpToDate(p1))
      M_throw() << "Particle 1 is not up to date";
  
    if (!Sim->dynamics->isUpToDate(p2))
      M_throw() << "Particle 2 is not up to date";

    if (p1 == p2)
      M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif 

    double d = (_diameter->getProperty(p1.getID())
		+ _diameter->getProperty(p2.getID())) * 0.5;

    double l = (_lambda->getProperty(p1.getID())
		+ _lambda->getProperty(p2.getID())) * 0.5;

    IntEvent retval(p1, p2, HUGE_VAL, NONE, *this);

    if (isCaptured(p1, p2))
      {
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, d);
	if (dt != HUGE_VAL)
	  retval = IntEvent(p1, p2, dt, CORE, *this);

	dt = Sim->dynamics->SphereSphereOutRoot(p1, p2, l * d);
	if (retval.getdt() > dt)
	    retval = IntEvent(p1, p2, dt, STEP_OUT, *this);
      }
    else
      {
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, l * d);

      if (dt != HUGE_VAL)
	retval = IntEvent(p1, p2, dt, STEP_IN, *this);
      }

    return retval;
  }
Beispiel #22
0
  Event
  IThinThread::getEvent(const Particle &p1, const Particle &p2) const 
  {
#ifdef DYNAMO_DEBUG
    if (!Sim->dynamics->isUpToDate(p1))
      M_throw() << "Particle 1 is not up to date";
  
    if (!Sim->dynamics->isUpToDate(p2))
      M_throw() << "Particle 2 is not up to date";

    if (p1 == p2)
      M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif 

    const double d = _diameter->getProperty(p1, p2);
    const double l = _lambda->getProperty(p1, p2);

    Event retval(p1, std::numeric_limits<float>::infinity(), INTERACTION, NONE, ID, p2);

    if (isCaptured(p1, p2))
      {
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, d);
	if (dt != std::numeric_limits<float>::infinity())
	  retval = Event(p1, dt, INTERACTION, CORE, ID, p2);

	dt = Sim->dynamics->SphereSphereOutRoot(p1, p2, l * d);
	if (retval._dt > dt)
	  retval = Event(p1, dt, INTERACTION, STEP_OUT, ID, p2);
      }
    else
      {
	double dt = Sim->dynamics->SphereSphereInRoot(p1, p2, d);

	if (dt != std::numeric_limits<float>::infinity())
	  retval = Event(p1, dt, INTERACTION, CORE, ID, p2);
      }

    return retval;
  }
Beispiel #23
0
  IntEvent 
  ISWSequence::getEvent(const Particle &p1, 
			const Particle &p2) const 
  {    
#ifdef DYNAMO_DEBUG
    if (!Sim->dynamics.getLiouvillean().isUpToDate(p1))
      M_throw() << "Particle 1 is not up to date";
  
    if (!Sim->dynamics.getLiouvillean().isUpToDate(p2))
      M_throw() << "Particle 2 is not up to date";

    if (p1 == p2)
      M_throw() << "You shouldn't pass p1==p2 events to the interactions!";
#endif 

#ifdef DYNAMO_CollDebug
    std::cerr << "\n Testing p1 = " << p1.getID() << " p2 = " << p2.getID();
#endif
    CPDData colldat(*Sim, p1, p2);
  
    double d = (_diameter->getProperty(p1.getID())
		+ _diameter->getProperty(p2.getID())) * 0.5;

    double d2 = d * d;

    double l = (_lambda->getProperty(p1.getID())
		+ _lambda->getProperty(p2.getID())) * 0.5;
  
    double ld2 = d * l * d * l;

    IntEvent retval(p1, p2, HUGE_VAL, NONE, *this);

    if (isCaptured(p1, p2)) 
      {
	if (Sim->dynamics.getLiouvillean()
	    .SphereSphereInRoot(colldat, d2,
				p1.testState(Particle::DYNAMIC), p2.testState(Particle::DYNAMIC))) 
	  {
#ifdef DYNAMO_OverlapTesting
	    //Check that there is no overlap 
	    if (Sim->dynamics.getLiouvillean().sphereOverlap(colldat, d2))
	      M_throw() << "Overlapping particles found" 
			<< ", particle1 " << p1.getID() 
			<< ", particle2 " 
			<< p2.getID() << "\nOverlap = " << (sqrt(colldat.r2) - sqrt(d2))/Sim->dynamics.units().unitLength();
#endif	  
	    retval = IntEvent(p1, p2, colldat.dt, CORE, *this);
	  }
      
	if (Sim->dynamics.getLiouvillean()
	    .SphereSphereOutRoot(colldat, ld2,
				 p1.testState(Particle::DYNAMIC), p2.testState(Particle::DYNAMIC)))
	  if (retval.getdt() > colldat.dt)
	    retval = IntEvent(p1, p2, colldat.dt, WELL_OUT, *this);
      }
    else if (Sim->dynamics.getLiouvillean()
	     .SphereSphereInRoot(colldat, ld2,
				 p1.testState(Particle::DYNAMIC), p2.testState(Particle::DYNAMIC))) 
      {
#ifdef DYNAMO_OverlapTesting
	if (Sim->dynamics.getLiouvillean().sphereOverlap(colldat,ld2))
	  {
	    if (Sim->dynamics.getLiouvillean().sphereOverlap(colldat,d2))
	      M_throw() << "Overlapping cores (but not registerd as captured) particles found in square well" 
			<< "\nparticle1 " << p1.getID() << ", particle2 " 
			<< p2.getID() << "\nOverlap = " << (sqrt(colldat.r2) - sqrt(d2))/Sim->dynamics.units().unitLength();
	    else
	      M_throw() << "Overlapping wells (but not registerd as captured) particles found" 
			<< "\nparticle1 " << p1.getID() << ", particle2 " 
			<< p2.getID() << "\nOverlap = " << (sqrt(colldat.r2) - sqrt(ld2))/Sim->dynamics.units().unitLength();
	  
	  }
#endif
	retval = IntEvent(p1, p2, colldat.dt, WELL_IN, *this);
      }

    return retval;
  }
Beispiel #24
0
  bool
  ISWSequence::validateState(const Particle& p1, const Particle& p2, bool textoutput) const
  {
    const double d = _diameter->getProperty(p1, p2);
    const double l = _lambda->getProperty(p1, p2);
    
    const double pairenergy = alphabet[sequence[p1.getID() % sequence.size()]][sequence[p2.getID() % sequence.size()]] * _unitEnergy->getMaxValue();

    /*Check if there is no well interaction between the pair*/
    if (pairenergy == 0)
      {
	if (Sim->dynamics->sphereOverlap(p1, p2, d))
	  {
	    if (textoutput)
	      derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		   << " have entered the core at " << d / Sim->units.unitLength()
		   << " and are at a distance of " 
		   << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		   << std::endl;
	    return true;
	  }
	else
	  return false;
      }

    if (isCaptured(p1, p2))
      {
	if (!Sim->dynamics->sphereOverlap(p1, p2, l * d))
	  {
	    if (textoutput)
	      derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		   << " registered as being inside the well at " << l * d / Sim->units.unitLength()
		   << " but they are at a distance of " 
		   << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		   << std::endl;
	    
	    return true;
	  }

	if (Sim->dynamics->sphereOverlap(p1, p2, d))
	  {
	    if (textoutput)
	      derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		   << " are inside the well with an inner hard core at " << d / Sim->units.unitLength()
		   << " but they are at a distance of " 
		   << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		   << std::endl;
	    
	    return true;
	  }
      }
    else
      if (Sim->dynamics->sphereOverlap(p1, p2, l * d))
	{
	  if (textoutput)
	    derr << "Particle " << p1.getID() << " and Particle " << p2.getID() 
		 << " are registered as being outside the well at a distance of " << l * d / Sim->units.unitLength()
		 << " but they are at a distance of "
		 << Sim->BCs->getDistance(p1, p2) / Sim->units.unitLength()
		 << std::endl;
	  
	  return true;
	}
    return false;
  }
Beispiel #25
0
 void ColorNode::deselect()
 {
     m_flags &= ~IsSelectedMask;
     
     setFrame( isCaptured() ? ColorNodeFrames::get()->captured_frame : ColorNodeFrames::get()->deselected_frame );
 }