Exemplo n.º 1
0
  void
  OPMisc::periodicOutput()
  {
    time_t rawtime;
    time(&rawtime);

    tm timeInfo;
    localtime_r (&rawtime, &timeInfo);

    char dateString[12] = "";
    strftime(dateString, 12, "%a %H:%M", &timeInfo);

    //Output the date
    I_Pcout() << dateString;

    //Calculate the ETA of the simulation, and take care with overflows and the like
    double _earliest_end_time = HUGE_VAL;
    BOOST_FOREACH(const std::tr1::shared_ptr<System>& sysPtr, Sim->systems)
      if (std::tr1::dynamic_pointer_cast<SystHalt>(sysPtr))
	_earliest_end_time = std::min(_earliest_end_time, sysPtr->getdt());

    double time_seconds_remaining = _earliest_end_time 
      / (getSimTimePerSecond() * Sim->units.unitTime());

    size_t seconds_remaining = time_seconds_remaining;
    
    if (time_seconds_remaining > std::numeric_limits<size_t>::max())
      seconds_remaining = std::numeric_limits<size_t>::max();

    if (Sim->endEventCount != std::numeric_limits<size_t>::max())
      {
	double event_seconds_remaining = (Sim->endEventCount - Sim->eventCount) / getEventsPerSecond() + 0.5;
	
	if (event_seconds_remaining < std::numeric_limits<size_t>::max())
	  seconds_remaining = std::min(seconds_remaining, size_t(event_seconds_remaining));

      }
  
    if (seconds_remaining != std::numeric_limits<size_t>::max())
      {
	size_t ETA_hours = seconds_remaining / 3600;
	size_t ETA_mins = (seconds_remaining / 60) % 60;
	size_t ETA_secs = seconds_remaining % 60;

	I_Pcout() << ", ETA ";
	if (ETA_hours)
	  I_Pcout() << ETA_hours << "hr ";
	  
	if (ETA_mins)
	  I_Pcout() << ETA_mins << "min ";

	I_Pcout() << ETA_secs << "s";
      }

    I_Pcout() << ", Events " << (Sim->eventCount+1)/1000 << "k, t "
	      << Sim->systemTime/Sim->units.unitTime() 
	      << ", <MFT> " <<  getMFT()
	      << ", <T> " << getMeankT() / Sim->units.unitEnergy()
	      << ", U " << _internalE.current() / Sim->units.unitEnergy();
  }
Exemplo n.º 2
0
void
OPMisc::output(magnet::xml::XmlStream &XML)
{
  std::time_t tendTime;
  time(&tendTime);

  std::string sTime(std::ctime(&tstartTime));
  //A hack to remove the newline character at the end
  sTime[sTime.size()-1] = ' ';

  std::string eTime(std::ctime(&tendTime));
  //A hack to remove the newline character at the end
  eTime[eTime.size()-1] = ' ';

  timespec acc_tendTime;
  clock_gettime(CLOCK_MONOTONIC, &acc_tendTime);

  double duration = double(acc_tendTime.tv_sec) - double(acc_tstartTime.tv_sec)
    + 1e-9 * (double(acc_tendTime.tv_nsec) - double(acc_tstartTime.tv_nsec));

  double collpersec = static_cast<double>(Sim->eventCount) / duration;

  dout << "Ended on " << eTime
       << "\nTotal Collisions Executed " << Sim->eventCount
       << "\nAvg Coll/s " << collpersec
       << "\nSim time per second "
       << Sim->dSysTime 
    / (Sim->dynamics.units().unitTime() * duration) 
       << std::endl;

  XML << magnet::xml::tag("Misc")
      << magnet::xml::tag("Memusage")
      << magnet::xml::attr("MaxKiloBytes") << magnet::process_mem_usage()
      << magnet::xml::endtag("Memusage")
      << magnet::xml::tag("Density")
      << magnet::xml::attr("val") 
      << Sim->dynamics.getNumberDensity() * Sim->dynamics.units().unitVolume()
      << magnet::xml::endtag("Density")

      << magnet::xml::tag("PackingFraction")
      << magnet::xml::attr("val") << Sim->dynamics.getPackingFraction()
      << magnet::xml::endtag("PackingFraction")

      << magnet::xml::tag("SpeciesCount")
      << magnet::xml::attr("val") << Sim->dynamics.getSpecies().size()
      << magnet::xml::endtag("SpeciesCount")

      << magnet::xml::tag("ParticleCount")
      << magnet::xml::attr("val") << Sim->N
      << magnet::xml::endtag("ParticleCount")

      << magnet::xml::tag("SimLength")
      << magnet::xml::attr("Collisions") << Sim->eventCount
      << magnet::xml::attr("OneParticleEvents") << singleEvents
      << magnet::xml::attr("TwoParticleEvents") << dualEvents
      << magnet::xml::attr("Time") << Sim->dSysTime / Sim->dynamics.units().unitTime()
      << magnet::xml::endtag("SimLength")

      << magnet::xml::tag("Timing")

      << magnet::xml::tag("Start")
      << magnet::xml::attr("val") << sTime
      << magnet::xml::endtag("Start")

      << magnet::xml::tag("End")
      << magnet::xml::attr("val") << eTime
      << magnet::xml::endtag("End")

      << magnet::xml::tag("Duration")
      << magnet::xml::attr("val")
      << duration
      << magnet::xml::endtag("Duration")

      << magnet::xml::tag("CollPerSec")
      << magnet::xml::attr("val") << collpersec
      << magnet::xml::attr("CondorWarning") << std::string("true")
      << magnet::xml::endtag("CollPerSec")

      << magnet::xml::endtag("Timing")
      << magnet::xml::tag("SystemBoxLength")
      << magnet::xml::attr("val")
      << 1.0/Sim->dynamics.units().unitLength();

  char name[2] = "x";
  for (size_t iDim = 0; iDim < NDIM; iDim++)
    {
      name[0] = 'x' + iDim;
      XML << magnet::xml::tag(name) << magnet::xml::attr("val")
	  << Sim->primaryCellSize[iDim]/Sim->dynamics.units().unitLength()
	  << magnet::xml::endtag(name);
    }

  XML << magnet::xml::endtag("SystemBoxLength");

  Vector sumMV(0, 0, 0);
  //Determine the discrepancy VECTOR
  BOOST_FOREACH( const Particle & Part, Sim->particleList)
    sumMV += Part.getVelocity() * Sim->dynamics.getSpecies(Part).getMass(Part.getID());

  XML << magnet::xml::tag("Total_momentum")
      << sumMV / Sim->dynamics.units().unitMomentum()
      << magnet::xml::endtag("Total_momentum")
      << magnet::xml::tag("totMeanFreeTime")
      << magnet::xml::attr("val")
      << getMFT()
      << magnet::xml::endtag("totMeanFreeTime");

  XML << magnet::xml::tag("MemoryUsage")
      << magnet::xml::attr("ResidentSet") << magnet::process_mem_usage()
      << magnet::xml::endtag("MemoryUsage")
      << magnet::xml::endtag("Misc");
}
Exemplo n.º 3
0
  void
  OPMisc::output(magnet::xml::XmlStream &XML)
  {
    std::time_t tendTime;
    time(&tendTime);

    std::string sTime(std::ctime(&tstartTime));
    //A hack to remove the newline character at the end
    sTime[sTime.size()-1] = ' ';

    std::string eTime(std::ctime(&tendTime));
    //A hack to remove the newline character at the end
    eTime[eTime.size()-1] = ' ';

    dout << "Ended on " << eTime
	 << "\nTotal Collisions Executed " << Sim->eventCount
	 << "\nAvg Events/s " << getEventsPerSecond()
	 << "\nSim time per second " << getSimTimePerSecond()
	 << std::endl;

    const double V = Sim->getSimVolume();

    const Matrix collP = collisionalP / (V * Sim->systemTime);
    
    const Matrix P = (_kineticP.mean() + collisionalP / Sim->systemTime) 
      / V;

    XML << magnet::xml::tag("Misc")
	<< magnet::xml::tag("Density")
	<< magnet::xml::attr("val")
	<< Sim->getNumberDensity() * Sim->units.unitVolume()
	<< magnet::xml::endtag("Density")

	<< magnet::xml::tag("PackingFraction")
	<< magnet::xml::attr("val") << Sim->getPackingFraction()
	<< magnet::xml::endtag("PackingFraction")

	<< magnet::xml::tag("SpeciesCount")
	<< magnet::xml::attr("val") << Sim->species.size()
	<< magnet::xml::endtag("SpeciesCount")

	<< magnet::xml::tag("ParticleCount")
	<< magnet::xml::attr("val") << Sim->N
	<< magnet::xml::endtag("ParticleCount")

	<< magnet::xml::tag("SystemMomentum")
	<< magnet::xml::tag("Current")
	<< magnet::xml::attr("x") << _sysMomentum.current()[0] / Sim->units.unitMomentum()
	<< magnet::xml::attr("y") << _sysMomentum.current()[1] / Sim->units.unitMomentum()
	<< magnet::xml::attr("z") << _sysMomentum.current()[2] / Sim->units.unitMomentum()
	<< magnet::xml::endtag("Current")
	<< magnet::xml::tag("Average")
	<< magnet::xml::attr("x") << _sysMomentum.mean()[0] / Sim->units.unitMomentum()
	<< magnet::xml::attr("y") << _sysMomentum.mean()[1] / Sim->units.unitMomentum()
	<< magnet::xml::attr("z") << _sysMomentum.mean()[2] / Sim->units.unitMomentum()
	<< magnet::xml::endtag("Average")
	<< magnet::xml::endtag("SystemMomentum")

	<< magnet::xml::tag("Temperature")
	<< magnet::xml::attr("Mean") << getMeankT() / Sim->units.unitEnergy()
	<< magnet::xml::attr("MeanSqr") << getMeanSqrkT() / (Sim->units.unitEnergy() * Sim->units.unitEnergy())
	<< magnet::xml::attr("Current") << getCurrentkT() / Sim->units.unitEnergy()
	<< magnet::xml::attr("Min") << 2.0 * _KE.min() / (Sim->N * Sim->dynamics->getParticleDOF() * Sim->units.unitEnergy())
	<< magnet::xml::attr("Max") << 2.0 * _KE.max() / (Sim->N * Sim->dynamics->getParticleDOF() * Sim->units.unitEnergy())
	<< magnet::xml::endtag("Temperature")

	<< magnet::xml::tag("UConfigurational")
	<< magnet::xml::attr("Mean") << getMeanUConfigurational() / Sim->units.unitEnergy()
	<< magnet::xml::attr("MeanSqr") << getMeanSqrUConfigurational() / (Sim->units.unitEnergy() * Sim->units.unitEnergy())
	<< magnet::xml::attr("Current") << _internalE.current() / Sim->units.unitEnergy()
	<< magnet::xml::attr("Min") << _internalE.min() / Sim->units.unitEnergy()
	<< magnet::xml::attr("Max") << _internalE.max() / Sim->units.unitEnergy()
	<< magnet::xml::endtag("UConfigurational")

	<< magnet::xml::tag("ResidualHeatCapacity")
	<< magnet::xml::attr("Value") 
	<< (getMeanSqrUConfigurational() - getMeanUConfigurational() * getMeanUConfigurational())
      / (getMeankT() * getMeankT())
	<< magnet::xml::endtag("ResidualHeatCapacity")
	<< magnet::xml::tag("Pressure")
	<< magnet::xml::attr("Avg") << P.tr() / (3.0 * Sim->units.unitPressure())
	<< magnet::xml::tag("Tensor") << magnet::xml::chardata()
      ;
    
    for (size_t iDim = 0; iDim < NDIM; ++iDim)
      {
	for (size_t jDim = 0; jDim < NDIM; ++jDim)
	  XML << P(iDim, jDim) / Sim->units.unitPressure() << " ";
	XML << "\n";
      }
    
    XML << magnet::xml::endtag("Tensor")
	<< magnet::xml::tag("InteractionContribution") << magnet::xml::chardata()
      ;
    
    for (size_t iDim = 0; iDim < NDIM; ++iDim)
      {
	for (size_t jDim = 0; jDim < NDIM; ++jDim)
	  XML << collP(iDim, jDim) / Sim->units.unitPressure() << " ";
	XML << "\n";
      }
    
    XML << magnet::xml::endtag("InteractionContribution")
	<< magnet::xml::endtag("Pressure")
	<< magnet::xml::tag("Duration")
	<< magnet::xml::attr("Events") << Sim->eventCount
	<< magnet::xml::attr("OneParticleEvents") << _singleEvents
	<< magnet::xml::attr("TwoParticleEvents") << _dualEvents
	<< magnet::xml::attr("VirtualEvents") << _virtualEvents
	<< magnet::xml::attr("Time") << Sim->systemTime / Sim->units.unitTime()
	<< magnet::xml::endtag("Duration")
	<< magnet::xml::tag("EventCounters");
  
    typedef std::pair<EventKey, size_t> mappair;
    BOOST_FOREACH(const mappair& mp1, _counters)
      XML << magnet::xml::tag("Entry")
	  << magnet::xml::attr("Type") << getClass(mp1.first.first)
	  << magnet::xml::attr("Name") << getName(mp1.first.first, Sim)
	  << magnet::xml::attr("Event") << mp1.first.second
	  << magnet::xml::attr("Count") << mp1.second
	  << magnet::xml::endtag("Entry");
  
    XML << magnet::xml::endtag("EventCounters")
	<< magnet::xml::tag("Timing")
	<< magnet::xml::attr("Start") << sTime
	<< magnet::xml::attr("End") << eTime
	<< magnet::xml::attr("EventsPerSec") << getEventsPerSecond()
	<< magnet::xml::attr("SimTimePerSec") << getSimTimePerSecond()
	<< magnet::xml::endtag("Timing")

	<< magnet::xml::tag("PrimaryImageSimulationSize")
	<< Sim->primaryCellSize / Sim->units.unitLength()
	<< magnet::xml::endtag("PrimaryImageSimulationSize")
	<< magnet::xml::tag("totMeanFreeTime")
	<< magnet::xml::attr("val")
	<< getMFT()
	<< magnet::xml::endtag("totMeanFreeTime")
	<< magnet::xml::tag("NegativeTimeEvents")
	<< magnet::xml::attr("Count") << _reverseEvents
	<< magnet::xml::endtag("NegativeTimeEvents")
	<< magnet::xml::tag("Memusage")
	<< magnet::xml::attr("MaxKiloBytes") << magnet::process_mem_usage()
	<< magnet::xml::endtag("Memusage")
	<< magnet::xml::tag("ThermalConductivity")
	<< magnet::xml::tag("Correlator")
	<< magnet::xml::chardata();

    {
      std::vector<magnet::math::LogarithmicTimeCorrelator<Vector>::Data>
	data = _thermalConductivity.getAveragedCorrelator();
    
      double inv_units = Sim->units.unitk()
	/ ( Sim->units.unitTime() * Sim->units.unitThermalCond() * 2.0 
	    * std::pow(getMeankT(), 2) * V);

      XML << "0 0 0 0 0\n";
      for (size_t i(0); i < data.size(); ++i)
	XML << data[i].time / Sim->units.unitTime() << " "
	    << data[i].sample_count << " "
	    << data[i].value[0] * inv_units << " "
	    << data[i].value[1] * inv_units << " "
	    << data[i].value[2] * inv_units << "\n";
    }

    XML << magnet::xml::endtag("Correlator")
	<< magnet::xml::endtag("ThermalConductivity")
	<< magnet::xml::tag("Viscosity")
	<< magnet::xml::tag("Correlator")
	<< magnet::xml::chardata();

    {
      std::vector<magnet::math::LogarithmicTimeCorrelator<Matrix>::Data>
	data = _viscosity.getAveragedCorrelator();
      
      double inv_units = 1.0
	/ (Sim->units.unitTime() * Sim->units.unitViscosity() * 2.0 * getMeankT()
	   * V);

      XML << "0 0 0 0 0 0 0 0 0 0 0\n";
      for (size_t i(0); i < data.size(); ++i)
	{
	  XML << data[i].time / Sim->units.unitTime() << " "
	      << data[i].sample_count << " ";
	  
	  for (size_t j(0); j < 3; ++j)
	    for (size_t k(0); k < 3; ++k)
	      XML << (data[i].value(j,k) - std::pow(data[i].time * P(j, k) * V, 2)) * inv_units << " ";
	  XML << "\n";
	}
    }

    XML << magnet::xml::endtag("Correlator")
	<< magnet::xml::endtag("Viscosity")
	<< magnet::xml::tag("ThermalDiffusion");

    for (size_t i(0); i < Sim->species.size(); ++i)
      {
	XML << magnet::xml::tag("Correlator")
	    << magnet::xml::attr("Species") << Sim->species[i]->getName()
	    << magnet::xml::chardata();
	
	std::vector<magnet::math::LogarithmicTimeCorrelator<Vector>::Data>
	  data = _thermalDiffusion[i].getAveragedCorrelator();
	
	double inv_units = 1.0
	  / (Sim->units.unitTime() * Sim->units.unitThermalDiffusion() * 2.0 * getMeankT() * V);
	
	XML << "0 0 0 0 0\n";
	for (size_t i(0); i < data.size(); ++i)
	  {
	    XML << data[i].time / Sim->units.unitTime() << " "
		<< data[i].sample_count << " ";
	    
	    for (size_t j(0); j < 3; ++j)
	      XML << data[i].value[j] * inv_units << " ";
	    XML << "\n";
	  }
	
	XML << magnet::xml::endtag("Correlator");
      }

    XML << magnet::xml::endtag("ThermalDiffusion")
	<< magnet::xml::tag("MutualDiffusion");

    for (size_t i(0); i < Sim->species.size(); ++i)
      for (size_t j(i); j < Sim->species.size(); ++j)
      {
	XML << magnet::xml::tag("Correlator")
	    << magnet::xml::attr("Species1") << Sim->species[i]->getName()
	    << magnet::xml::attr("Species2") << Sim->species[j]->getName()
	    << magnet::xml::chardata();
	
	std::vector<magnet::math::LogarithmicTimeCorrelator<Vector>::Data>
	  data = _mutualDiffusion[i * Sim->species.size() + j].getAveragedCorrelator();
	
	double inv_units = 1.0
	  / (Sim->units.unitTime() * Sim->units.unitMutualDiffusion() * 2.0 * getMeankT() * V);
	
	XML << "0 0 0 0 0\n";
	for (size_t i(0); i < data.size(); ++i)
	  {
	    XML << data[i].time / Sim->units.unitTime() << " "
		<< data[i].sample_count << " ";
	    
	    for (size_t j(0); j < 3; ++j)
	      XML << data[i].value[j] * inv_units << " ";
	    XML << "\n";
	  }
	
	XML << magnet::xml::endtag("Correlator");
      }

    XML << magnet::xml::endtag("MutualDiffusion")
	<< magnet::xml::endtag("Misc");
  }