Example #1
0
void 
IStepped::operator<<(const magnet::xml::Node& XML)
{
  if (strcmp(XML.getAttribute("Type"),"Stepped"))
    M_throw() << "Attempting to load Stepped from non Stepped entry";
  
  range.set_ptr(C2Range::getClass(XML,Sim));
  
  try {
    intName = XML.getAttribute("Name");

    if (!XML.hasNode("Step"))
      M_throw() << "No steppings defined for stepped potential " 
		<< intName;

    for (magnet::xml::Node node = XML.fastGetNode("Step"); node.valid(); ++node)
      steps.push_back(steppair(node.getAttribute("R").as<double>(),
			       node.getAttribute("E").as<double>()));
    
    std::sort(steps.rbegin(), steps.rend());

    IMultiCapture::loadCaptureMap(XML);
  }
  catch (boost::bad_lexical_cast &)
    {
      M_throw() << "Failed a lexical cast in CIStepped";
    }

  if (steps.empty())
    M_throw() << "No steps defined in SteppedPotential Interaction with name " 
	      << getName();
}
Example #2
0
  void 
  LOscillatingPlate::operator<<(const magnet::xml::Node& XML)
  {
    range = shared_ptr<Range>(Range::getClass(XML,Sim));
  
    try {
      e = XML.getAttribute("Elasticity").as<double>();
      nhat << XML.getNode("Norm");
      nhat /= nhat.nrm();

      rw0 << XML.getNode("Origin");
      rw0 *= Sim->dynamics.units().unitLength();

      if (XML.hasAttribute("StrongPlate"))
	strongPlate = XML.getAttribute("StrongPlate").as<double>();

      omega0 = XML.getAttribute("Omega0").as<double>() / Sim->dynamics.units().unitTime();
      sigma = XML.getAttribute("Sigma").as<double>() * Sim->dynamics.units().unitLength();
      delta = XML.getAttribute("Delta").as<double>() * Sim->dynamics.units().unitLength();
      mass = XML.getAttribute("Mass").as<double>()  * Sim->dynamics.units().unitMass();
      timeshift = XML.getAttribute("TimeShift").as<double>() * Sim->dynamics.units().unitTime();

      localName = XML.getAttribute("Name");
    } 
    catch (boost::bad_lexical_cast &)
      {
	M_throw() << "Failed a lexical cast in LOscillatingPlate";
      }
  }
Example #3
0
 void 
 Topology::operator<<(const magnet::xml::Node& XML)
 {
   _name = XML.getAttribute("Name");
   
   if (!XML.hasNode("Molecule"))
     M_throw() << "Cannot load a Topology which has no molecules!";
 }
Example #4
0
 C2RPair::C2RPair(const magnet::xml::Node& XML, const dynamo::SimData* Sim)
 { 
   if (strcmp(XML.getAttribute("Range"), "Pair"))
     M_throw() << "Attempting to load a pair from a non pair";
 
   range1 = shared_ptr<Range>(Range::getClass(XML.getNode("Range1"), Sim));
   range2 = shared_ptr<Range>(Range::getClass(XML.getNode("Range2"), Sim));
 }
Example #5
0
 void 
 IDSMC::operator<<(const magnet::xml::Node& XML)
 { 
   Interaction::operator<<(XML);
   _length = Sim->_properties.getProperty(XML.getAttribute("Length"), Property::Units::Length());
   _e = Sim->_properties.getProperty(XML.getAttribute("Elasticity"), Property::Units::Dimensionless());
   ICapture::loadCaptureMap(XML);   
 }
Example #6
0
  void 
  OPRGyration::operator<<(const magnet::xml::Node& XML)
  {
    if (XML.hasAttribute("BinWidthGyration"))
      _binWidthGyration = XML.getAttribute("BinWidthGyration").as<double>();

    if (XML.hasAttribute("BinWidthGyration"))
      _binWidthNematic = XML.getAttribute("BinWidthGyration").as<double>();
  }
Example #7
0
  shared_ptr<Topology>
  Topology::getClass(const magnet::xml::Node& XML, dynamo::Simulation* Sim, size_t ID)
  {
    if (!strcmp(XML.getAttribute("Type"),"Chain"))
      return shared_ptr<Topology>(new TChain(XML, Sim, ID));
    else 
      M_throw() << XML.getAttribute("Type")
		<< ", Unknown type of Topology encountered";
  }
Example #8
0
 void
 SSleep::operator<<(const magnet::xml::Node& XML)
 {
   sysName = XML.getAttribute("Name");
   _sleepVelocity = XML.getAttribute("SleepV").as<double>() * Sim->units.unitVelocity();
   _sleepDistance = Sim->units.unitLength() * 0.01;
   _sleepTime = Sim->units.unitTime() * 0.0001;
   _range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"), Sim));
 }
Example #9
0
Particle::Particle(const magnet::xml::Node& XML, unsigned long nID):
  _ID(nID),
  _peculiarTime(0.0),
  _state(DEFAULT)
{
  if (XML.hasAttribute("Static")) clearState(DYNAMIC);

  _pos << XML.getNode("P");
  _vel << XML.getNode("V");
}
Example #10
0
    inline ParticleProperty(const magnet::xml::Node& node):
      Property(Property::Units(node.getAttribute("Units").getValue())),
      _name(node.getAttribute("Name").getValue())
    {
      //Move up to the particles nodes, and start loading the property values
      for (magnet::xml::Node pNode = node.getParent().getParent()
	     .getNode("ParticleData").fastGetNode("Pt");
	   pNode.valid(); ++pNode)
	_values.push_back(pNode.getAttribute(_name).as<double>());
    }
Example #11
0
 void 
 GFrancesco::operator<<(const magnet::xml::Node& XML)
 {
   globName = XML.getAttribute("Name");
   const double MFT = XML.getAttribute("MFT").as<double>() * Sim->units.unitTime();
   const double MFTstddev = XML.getAttribute("MFTstddev").as<double>() * Sim->units.unitTime();
   _dist = std::normal_distribution<>(MFT, MFTstddev);
   _vel = XML.getAttribute("Velocity").as<double>() * Sim->units.unitVelocity();
   range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"), Sim));
 }
Example #12
0
  void 
  SysRescale::operator<<(const magnet::xml::Node& XML)
  {
    if (strcmp(XML.getAttribute("Type"),"Rescale"))
      M_throw() << "Attempting to load Rescale from " 
		<< XML.getAttribute("Type") << " entry"; 
  
    try {
      if (XML.hasAttribute("Freq"))
	_frequency = XML.getAttribute("Freq").as<size_t>();
    
      if (XML.hasAttribute("kT"))
	_kT = XML.getAttribute("kT").as<double>();
    
      _kT *= Sim->dynamics.units().unitEnergy();

      if (XML.hasAttribute("TimeStep"))
	_timestep = XML.getAttribute("TimeStep").as<double>();

      _timestep *= Sim->dynamics.units().unitTime();

      sysName = XML.getAttribute("Name");
    }
    catch (boost::bad_lexical_cast &)
      {
	M_throw() << "Failed a lexical cast in SysRescale";
      }
  }
Example #13
0
void
CSUmbrella::operator<<(const magnet::xml::Node& XML)
{
  if (strcmp(XML.getAttribute("Type"),"Umbrella"))
    M_throw() << "Attempting to load Umbrella from a " 
	      << XML.getAttribute("Type") <<  " entry"; 
  
  try {
    sysName = XML.getAttribute("Name");

    a = XML.getAttribute("a").as<double>()
      * Sim->dynamics.units().unitEnergy() 
      / Sim->dynamics.units().unitArea();

    b = XML.getAttribute("b").as<double>()
      * Sim->dynamics.units().unitLength();

    delU = XML.getAttribute("delU").as<double>() * Sim->dynamics.units().unitEnergy();
    range1.set_ptr(CRange::getClass(XML.getNode("Range1"), Sim));
    range2.set_ptr(CRange::getClass(XML.getNode("Range2"), Sim));
    
    if (XML.hasAttribute("currentulevel"))
      {
	ulevel = XML.getAttribute("currentulevel").as<size_t>();
	ulevelset = true;
      }
    
  }
  catch (boost::bad_lexical_cast &)
    { M_throw() << "Failed a lexical cast in CSUmbrella"; }
}
Example #14
0
 void 
 BCLeesEdwards::operator<<(const magnet::xml::Node& XML)
 { 
   if (XML.hasAttribute("DXD"))
     _dxd = XML.getAttribute("DXD").as<double>();
   _dxd *= Sim->units.unitLength();
   
   if (XML.hasAttribute("Rate"))
     _shearRate = XML.getAttribute("Rate").as<double>();      
   _shearRate /= Sim->units.unitTime();
 }
Example #15
0
    IDPairRangeChainGroups(const magnet::xml::Node& XML, const dynamo::Simulation*):
      range1(0),range2(0), length(0) 
    { 
      range1 = XML.getAttribute("Start1").as<size_t>();
      range2 = XML.getAttribute("Start2").as<size_t>();
      length = XML.getAttribute("Length").as<size_t>();

      //Guarrantee that they are ordered
      if (range1 > range2)
	std::swap(range1, range2);
    }
Example #16
0
 void 
 OPStructureImaging::operator<<(const magnet::xml::Node& XML)
 {
   if (!XML.hasAttribute("Structure"))
     M_throw() << "You must specify the name of the structure to monitor for StructureImaging";
   
   structureName = XML.getAttribute("Structure");
   
   if (XML.hasAttribute("MaxImages"))
     imageCount = XML.getAttribute("MaxImages").as<size_t>();
 }
Example #17
0
  shared_ptr<Potential>
  Potential::getClass(const magnet::xml::Node& XML)
  {
    if (!XML.getAttribute("Type").getValue().compare("Stepped"))
      return shared_ptr<Potential>(new PotentialStepped(XML));
    else if (!XML.getAttribute("Type").getValue().compare("LennardJones"))
      return shared_ptr<Potential>(new PotentialLennardJones(XML));
    else 
      M_throw() << XML.getAttribute("Type").getValue()
		<< ", Unknown type of Potential encountered";
  }
Example #18
0
  void 
  IHardSphere::operator<<(const magnet::xml::Node& XML)
  { 
    Interaction::operator<<(XML);
    _diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"), Property::Units::Length());

    if (XML.hasAttribute("Elasticity"))
      _e = Sim->_properties.getProperty(XML.getAttribute("Elasticity"), Property::Units::Dimensionless());
    
    if (XML.hasAttribute("TangentialElasticity"))
      _et = Sim->_properties.getProperty(XML.getAttribute("TangentialElasticity"), Property::Units::Dimensionless());
  }
Example #19
0
  void 
  Topology::operator<<(const magnet::xml::Node& XML)
  {
    try { spName = XML.getAttribute("Name"); } 
    catch (boost::bad_lexical_cast &)
      {
	M_throw() << "Failed a lexical cast in CTopology";
      }
    
    for (magnet::xml::Node node = XML.fastGetNode("Molecule"); node.valid(); ++node)
      ranges.push_back(shared_ptr<Range>(Range::getClass(node, Sim)));
  }
Example #20
0
  void checkNodeNameAttribute(magnet::xml::Node node)
  {
    //Check for unique names
    std::set<std::string> names;
    for (; node.valid(); ++node)
      {
	std::string currentname = node.getAttribute("Name").as<std::string>();
	if (names.find(currentname) != names.end())
	  M_throw() << node.getName() << " at path :" << node.getPath() << "\n Does not have a unique name (Name=\"" << currentname << "\")";
	names.insert(currentname);
      }
  }
void
OPMSDOrientationalCorrelator::operator<<(const magnet::xml::Node& XML)
{
  try {
    if (XML.hasAttribute("Length"))
      length = XML.getAttribute("Length").as<size_t>();
  }
  catch (boost::bad_lexical_cast &)
  {
    M_throw() << "Failed a lexical cast in OPMSDCorrelator";
  }
}
Example #22
0
  void 
  ICapture::loadCaptureMap(const magnet::xml::Node& XML)
  {
    if (XML.hasNode("CaptureMap"))
      {
	_mapUninitialised = false;
	clear();

	for (magnet::xml::Node node = XML.getNode("CaptureMap").findNode("Pair"); node.valid(); ++node)
	  Map::operator[](Map::key_type(node.getAttribute("ID1").as<size_t>(), node.getAttribute("ID2").as<size_t>()))
	    = node.getAttribute("val").as<size_t>();
      }
  }
Example #23
0
  C2RRings::C2RRings(const magnet::xml::Node& XML, const dynamo::SimData*):
    range1(0),range2(0), interval(0)
  { 
    if (strcmp(XML.getAttribute("Range"),"Rings"))
      M_throw() << "Attempting to load a rings from a non rings";
  
    range1 = XML.getAttribute("Start").as<unsigned long>();
    range2 = XML.getAttribute("End").as<unsigned long>();
    interval = XML.getAttribute("Interval").as<unsigned long>();

    if ((range2-range1 + 1) % interval)
      M_throw() << "Range of C2RChains does not split evenly into interval";
  }
Example #24
0
  shared_ptr<Dynamics>
  Dynamics::getClass(const magnet::xml::Node& XML, dynamo::Simulation* tmp)
  {
    if (!strcmp(XML.getAttribute("Type"),"Newtonian"))
      return shared_ptr<Dynamics>(new DynNewtonian(tmp));
    if (!strcmp(XML.getAttribute("Type"),"NewtonianGravity"))
      return shared_ptr<Dynamics>(new DynGravity(tmp, XML));
    else if (!strcmp(XML.getAttribute("Type"),"NewtonianMC"))
      return shared_ptr<Dynamics>(new DynNewtonianMC(tmp, XML));
    else
      M_throw() << XML.getAttribute("Type")
		<< ", Unknown type of Dynamics encountered";
  }
Example #25
0
  void 
  OPMFL::operator<<(const magnet::xml::Node& XML)
  {
    try 
      {
	if (XML.hasAttribute("binwidth"))
	  binwidth = XML.getAttribute("binwidth").as<double>();
      }
    catch (boost::bad_lexical_cast&)
      {
	M_throw() << "Failed a lexical cast in OPMFL";
      }
  }
Example #26
0
  shared_ptr<Scheduler>
  Scheduler::getClass(const magnet::xml::Node& XML, dynamo::Simulation* const Sim)
  {
    if (!XML.getAttribute("Type").getValue().compare("NeighbourList"))
      return shared_ptr<Scheduler>(new SNeighbourList(XML, Sim));
    else if (!XML.getAttribute("Type").getValue().compare("Dumb"))
      return shared_ptr<Scheduler>(new SDumb(XML, Sim));
    else if (!XML.getAttribute("Type").getValue().compare("SystemOnly"))
      return shared_ptr<Scheduler>(new SSystemOnly(XML, Sim));
    else 
      M_throw() << XML.getAttribute("Type").getValue()
		<< ", Unknown type of Scheduler encountered";
  }
Example #27
0
 void 
 IThinThread::operator<<(const magnet::xml::Node& XML)
 {
   Interaction::operator<<(XML);
   _diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"), Property::Units::Length());
   _lambda = Sim->_properties.getProperty(XML.getAttribute("Lambda"), Property::Units::Dimensionless());
   _wellDepth = Sim->_properties.getProperty(XML.getAttribute("WellDepth"), Property::Units::Energy());
   if (XML.hasAttribute("Elasticity"))
     _e = Sim->_properties.getProperty(XML.getAttribute("Elasticity"), Property::Units::Dimensionless());
   else
     _e = Sim->_properties.getProperty(1.0, Property::Units::Dimensionless());
   ICapture::loadCaptureMap(XML);   
 }
Example #28
0
  void 
  CSysGhost::operator<<(const magnet::xml::Node& XML)
  {
    if (strcmp(XML.getAttribute("Type"),"Andersen"))
      M_throw() << "Attempting to load Andersen from non Andersen entry"; 
  
    try {
      meanFreeTime = XML.getAttribute("MFT").as<double>() * Sim->dynamics.units().unitTime();
      Temp = XML.getAttribute("Temperature").as<double>() * Sim->dynamics.units().unitEnergy();
      sysName = XML.getAttribute("Name");

      if (XML.hasAttribute("SetFrequency") && XML.hasAttribute("SetPoint"))
	{
	  tune = true;
	  setFrequency = XML.getAttribute("SetFrequency").as<unsigned long long>();
	  setPoint = boost::lexical_cast<double>(XML.getAttribute("SetPoint"));
	}

      range = std::tr1::shared_ptr<CRange>(CRange::getClass(XML,Sim));
    }
    catch (boost::bad_lexical_cast &)
      {
	M_throw() << "Failed a lexical cast in CGGlobal";
      }
  }
Example #29
0
  void 
  Liouvillean::loadParticleXMLData(const magnet::xml::Node& XML)
  {
    dout << "Loading Particle Data" << std::endl;

    bool outofsequence = false;  
  
    for (magnet::xml::Node node = XML.getNode("ParticleData").fastGetNode("Pt"); 
	 node.valid(); ++node)
      {
	if (!node.hasAttribute("ID")
	    || node.getAttribute("ID").as<size_t>() != Sim->particleList.size())
	  outofsequence = true;
      
	Particle part(node, Sim->particleList.size());
	part.getVelocity() *= Sim->dynamics.units().unitVelocity();
	part.getPosition() *= Sim->dynamics.units().unitLength();
	Sim->particleList.push_back(part);
      }

    if (outofsequence)
      dout << "Particle ID's out of sequence!\n"
	   << "This can result in incorrect capture map loads etc.\n"
	   << "Erase any capture maps in the configuration file so they are regenerated." << std::endl;

    Sim->N = Sim->particleList.size();

    dout << "Particle count " << Sim->N << std::endl;

    if (XML.getNode("ParticleData").hasAttribute("OrientationData"))
      {
	orientationData.resize(Sim->N);
	size_t i(0);
	for (magnet::xml::Node node = XML.getNode("ParticleData").fastGetNode("Pt"); 
	     node.valid(); ++node, ++i)
	  {
	    orientationData[i].orientation << node.getNode("U");
	    orientationData[i].angularVelocity << node.getNode("O");
      
	    double oL = orientationData[i].orientation.nrm();
      
	    if (!(oL > 0.0))
	      M_throw() << "Particle ID " << i 
			<< " orientation vector is zero!";
      
	    //Makes the vector a unit vector
	    orientationData[i].orientation /= oL;
	  }
      }
  }
Example #30
0
  void 
  LWall::operator<<(const magnet::xml::Node& XML)
  {
    range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"),Sim));
    _diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"), Property::Units::Length());

    if (_diameter->getMaxValue() == 0)
      M_throw() << "Cannot have a wall with a diameter of zero";
      
    _e = Sim->_properties.getProperty(XML.getAttribute("Elasticity"), Property::Units::Dimensionless());
    
    sqrtT = 0;
    if (XML.hasAttribute("Temperature"))
      sqrtT = sqrt(XML.getAttribute("Temperature").as<double>()
		   * Sim->units.unitEnergy());

    if (sqrtT < 0)
      M_throw() << "Cannot use negative temperatures on a Wall";

    magnet::xml::Node xBrowseNode = XML.getNode("Norm");
    localName = XML.getAttribute("Name");
    vNorm << xBrowseNode;
    if (vNorm.nrm() == 0)
      M_throw() << "The normal for the Local Wall named \"" << getName() << "\" has a length of 0. Cannot load";
    vNorm /= vNorm.nrm();
    xBrowseNode = XML.getNode("Origin");
    vPosition << xBrowseNode;
    vPosition *= Sim->units.unitLength();
  }