NewtonsCradleSelfTest.cpp File Reference
#include "Mercury3D.h"
#include "StatisticsVector.h"
#include "Walls/InfiniteWall.h"
#include <array>
#include <Species/LinearViscoelasticSpecies.h>
#include <CG/TimeAveragedCG.h>

Classes

class  NewtonsCradleSelfTest
 

Functions

int main (int argc UNUSED, char *argv[] UNUSED)
 

Function Documentation

◆ main()

int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)
Todo:
TW the output of the old and new stat doesn't compare perfectly, check.
76 {
77  logger(INFO,"Simulating a stack of particles under gravity on a wall until it is relaxed");
78  NewtonsCradleSelfTest problem;
79  problem.setName("NewtonsCradleSelfTest");
81  problem.N=5; //set the number of particles
82  problem.setSystemDimensions(3);
83  problem.setParticleDimensions(3);
84  species->setDensity(6./pi);
85  problem.setGravity(Vec3D(0.,0.,-1.));
86  species->setCollisionTimeAndRestitutionCoefficient(.01,.1,1.);
87  problem.setTimeStep(0.0001);
88  problem.setTimeMax(8.0);
89  problem.setSaveCount(1000);
90  problem.solve();
91 
92  Mdouble w=0.46/3.;
93 
94  logger(INFO,"Test new cg handler");
95  Mercury3D cg;
97  c0->setNZ(400);
98  c0->setWidth(w);
99  cg.cgHandler.restartAndEvaluateDataFiles("NewtonsCradleSelfTest");
100 
102  helpers::writeToFile("NewtonsCradleSelfTest.gnu",
103  "p 'NewtonsCradleSelfTest.0.stat' u 2:22 w lp, 'NewtonsCradleSelfTest.stat' u 3:41 w l");
104 
105  StatisticsVector<Z> stats1("NewtonsCradleSelfTest");
106  stats1.setNZ(400);
107  stats1.setCGWidth(w);
108  stats1.setSuperExact(false);
109  stats1.setCGShape("Gaussian");
110  stats1.setCGTimeMin(problem.getTimeMax()*1.00000999999);
111  stats1.setTimeMaxStat(1e20);
112  //stats1.statFile.setName("NewtonsCradleSelfTest.old.stat");
113  logger(INFO,"Creating %",stats1.statFile.getName());
114  stats1.statistics_from_fstat_and_data();
115 
116  logger(INFO,"Test StatisticsVector for different CG functions (Gauss, Heaviside, Lucy)");
117  int i=0;
118  std::array<std::string,3> str = {"Gaussian","HeavisideSphere","Lucy"};
119 
120  for (int i=0; i<3; i++) {
121  double w=0.125;
122  if (i==1) w*=2;
123  if (i==2) w*=2*sqrt(3);
124 
125  StatisticsVector<Z> stats0("NewtonsCradleSelfTest");
126  stats0.setZMinStat(-0.5);
127  stats0.statFile.setName(stats0.getName() + "_" + str[i] + "Z.stat");
128  stats0.set_h(0.02);
129  stats0.verbose();
130  stats0.setCGWidth(w);
131  stats0.setSuperExact(true);
132  stats0.setCGShape(str[i].c_str());
133  stats0.setCGTimeMin(problem.getTimeMax()*.999999);
134  stats0.setTimeMaxStat(1e20);
135  logger(INFO,"Creating %",stats0.statFile.getName());
136  stats0.statistics_from_fstat_and_data();
137 
138  StatisticsVector<XYZ> stats2("NewtonsCradleSelfTest");
139  stats2.setZMinStat(-0.5);
140  stats2.statFile.setName(stats2.getName() + "_" + str[i] + "XYZ.stat");
141  stats2.set_h(0.02);
142  stats2.setNY(1);
143  stats2.setCGWidth(w);
144  stats2.setSuperExact(true);
145  stats2.setCGShape(str[i].c_str());
146  stats2.setCGTimeMin(problem.getTimeMax()*.999999);
147  stats2.setTimeMaxStat(1e20);
148  logger(INFO,"Creating %",stats2.statFile.getName());
149  stats2.statistics_from_fstat_and_data();
150  }
151 
152  return(0);
153 }
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
void restartAndEvaluateDataFiles(const std::string &name, bool evaluateFStatFiles=true)
Definition: CGHandler.cc:188
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:408
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1448
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1473
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1234
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1417
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:888
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
Definition: NewtonsCradleSelfTest.cpp:35
int N
Definition: NewtonsCradleSelfTest.cpp:72
This class is used to extract statistical data from MD simulations.
Definition: StatisticsVector.h:62
Evaluates time-averaged continuum fields and writes the data into a stat file.
Definition: TimeAveragedCG.h:59
Definition: Vector.h:51
const Mdouble pi
Definition: ExtendedMath.h:45
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58

References DPMBase::cgHandler, BaseHandler< T >::copyAndAddObject(), DPMBase::getName(), File::getName(), DPMBase::getTimeMax(), constants::i, INFO, logger, NewtonsCradleSelfTest::N, constants::pi, CGHandler::restartAndEvaluateDataFiles(), StatisticsVector< T >::set_h(), StatisticsVector< T >::setCGShape(), StatisticsVector< T >::setCGTimeMin(), StatisticsVector< T >::setCGWidth(), DPMBase::setGravity(), DPMBase::setName(), File::setName(), StatisticsVector< T >::setNY(), StatisticsVector< T >::setNZ(), DPMBase::setParticleDimensions(), DPMBase::setSaveCount(), StatisticsVector< T >::setSuperExact(), DPMBase::setSystemDimensions(), DPMBase::setTimeMax(), StatisticsVector< T >::setTimeMaxStat(), DPMBase::setTimeStep(), StatisticsVector< T >::setZMinStat(), DPMBase::solve(), DPMBase::speciesHandler, DPMBase::statFile, StatisticsVector< T >::statistics_from_fstat_and_data(), StatisticsVector< T >::verbose(), and helpers::writeToFile().