Exemple #1
0
  void 
  LBoundary::operator<<(const magnet::xml::Node& XML)
  {
    range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"),Sim));
    localName = XML.getAttribute("Name");

    _oscillationData._origin << XML.getNode("Origin");
    _oscillationData._origin *= Sim->units.unitLength();
    _diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"), Property::Units::Length());
    if (_diameter->getMaxValue() == 0)
      M_throw() << "Cannot have a boundary with a diameter of zero";

    _oscillationData._amplitude = Vector();
    _oscillationData._freq = 0;
    _oscillationData._t_shift = 0;
    
    const size_t data_count = XML.hasNode("Amplitude") + XML.hasAttribute("Frequency") + XML.hasAttribute("Phase");
    if ((data_count != 3) && (data_count != 0))
      M_throw() << "For oscillating walls you must have an Amplitude, Frequency, and Phase specified."
		<< XML.getPath();

    if (data_count == 3) {
      _oscillationData._freq = XML.getAttribute("Frequency").as<double>() / Sim->units.unitTime();
      _oscillationData._t_shift = XML.getAttribute("Phase").as<double>() * Sim->units.unitTime();
      _oscillationData._amplitude << XML.getNode("Amplitude");
      _oscillationData._amplitude *= Sim->units.unitLength();
    }

    _kT = 0;
    if (XML.hasAttribute("kT")) {
      if (data_count == 3)
	M_throw() << "Cannot have both a thermalised wall and a oscillating wall" 
		  << XML.getPath();
      
      _kT = XML.getAttribute("kT").as<double>() * Sim->units.unitEnergy();
    }

    if (_kT < 0)
      M_throw() << "Temperature is less than zero" << XML.getPath();

    for (magnet::xml::Node node = XML.findNode("Object"); node.valid(); ++node)
      _objects.push_back(boundary::Object::getClass(node, Sim, _oscillationData));

    if (_objects.empty())
      M_throw() << "Boundary Locals must have at least one Object.\n" << XML.getPath();
  }
Exemple #2
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);
      }
  }
Exemple #3
0
  void 
  PotentialLennardJones::operator<<(const magnet::xml::Node& XML) {
    _r_cache.clear();
    _u_cache.clear();

    _sigma = XML.getAttribute("Sigma").as<double>();
    _epsilon = XML.getAttribute("Epsilon").as<double>();
    _cutoff = XML.getAttribute("CutOff").as<double>();
    
    if (_cutoff <= minimum())
      M_throw() << "The cutoff (" << _cutoff << ") cannot be before the minimum (" 
		<< minimum() << ") in the potential for this Lennard-Jones potential due to the stepping parameters used. Please use a WCA potential instead (if available).";

    _r_cache.push_back(_cutoff);
    
    _attractiveSteps = XML.getAttribute("AttractiveSteps").as<double>();

    const std::string umode_string = XML.getAttribute("UMode").as<std::string>();
    if (!umode_string.compare("Midpoint"))    _U_mode = MIDPOINT;
    else if (!umode_string.compare("Left"))   _U_mode = LEFT;
    else if (!umode_string.compare("Right"))  _U_mode = RIGHT;
    else if (!umode_string.compare("Volume")) _U_mode = VOLUME;
    else if (!umode_string.compare("MidVolume")) _U_mode = MIDVOLUME;
    else if (!umode_string.compare("Virial")) 
      {
	_kT = XML.getAttribute("Temperature").as<double>();
	_U_mode = VIRIAL;
      }
    else
      M_throw() << "Unknown LennardJones UMode (" << umode_string << ") at " << XML.getPath();

    const std::string rmode_string = XML.getAttribute("RMode").as<std::string>();
    if (!rmode_string.compare("DeltaR"))      _R_mode = DELTAR;
    else if (!rmode_string.compare("DeltaU")) _R_mode = DELTAU;
    else if (!rmode_string.compare("DeltaV")) _R_mode = DELTAV;
    else
      M_throw() << "Unknown LennardJones RMode (" << rmode_string << ") at " << XML.getPath();
  }
Exemple #4
0
  void 
  PotentialStepped::operator<<(const magnet::xml::Node& XML) {
    if (XML.getAttribute("Direction").as<std::string>() == "Left")
      _direction = false;
    else if (XML.getAttribute("Direction").as<std::string>() == "Right")
      _direction = true;
    else
      M_throw() << "Could not parse Direction, should be either \"Left\" or \"Right\"\nXML path:"
		<< XML.getPath();

    std::vector<std::pair<double, double> > steps;
    for (magnet::xml::Node node = XML.fastGetNode("Step"); node.valid(); ++node)
      steps.push_back(std::pair<double, double>(node.getAttribute("R").as<double>(),
						node.getAttribute("E").as<double>()));
    
    if (steps.empty())
      M_throw() << "You cannot load a stepped potential with no steps.\nXML path: " << XML.getPath();
    
    *this = PotentialStepped(steps, _direction);
  }
Exemple #5
0
  void 
  GSOCells::operator<<(const magnet::xml::Node& XML)
  {
    globName = XML.getAttribute("Name");
    
    if (XML.hasNode("CellOrigins")) {
      Vector pos;
      for (magnet::xml::Node node = XML.getNode("CellOrigins").findNode("Origin"); node.valid(); ++node) {
	pos << node;
	pos *= Sim->units.unitLength();
	cell_origins.push_back(pos);
      }

      if (cell_origins.size() != Sim->N())
	M_throw() << "Number of CellOrigins (" << cell_origins.size() << ") does not match number of particles (" << Sim->N() << ")\n" << XML.getPath();
    }

    if (XML.hasAttribute("Diameter"))
      _cellD = XML.getAttribute("Diameter").as<double>() * Sim->units.unitLength();
  }