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.
55 {
56  logger(INFO,"Simulating a stack of particles under gravity on a wall until it is relaxed");
58  problem.setName("NewtonsCradleSelfTest");
59  auto species=problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
60  problem.N=5; //set the number of particles
61  problem.removeOldFiles();
62  problem.setSystemDimensions(3);
63  problem.setParticleDimensions(3);
64  species->setDensity(6./pi);
65  problem.setGravity(Vec3D(0.,0.,-1.));
66  species->setCollisionTimeAndRestitutionCoefficient(.01,.1,1.);
67  problem.setTimeStep(0.0001);
68  problem.setTimeMax(8.0);
69  problem.setSaveCount(1000);
70  problem.solve();
71 
72  Mdouble w=0.46/3.;
73 
74  logger(INFO,"\nTesting CGHandler::restartAndEvaluateDataFiles");
75 
76  Mercury3D cg;
78  c0->setNZ(400);
79  c0->setWidth(w);
80  c0->setTimeMin(8+1e-12);
81  c0->statFile.setName(problem.getName()+".fromData.stat");
82  cg.cgHandler.restartAndEvaluateDataFiles("NewtonsCradleSelfTest");
83 
84  logger(INFO,"\nTesting CGHandler::restartAndEvaluateRestartFiles");
85 
86  c0->statFile.setName(problem.getName()+".fromRestart.stat");
87  cg.cgHandler.restartAndEvaluateRestartFiles("NewtonsCradleSelfTest");
88 
90  helpers::writeToFile("NewtonsCradleSelfTest.gnu",
91  "p 'NewtonsCradleSelfTest.0.stat' u 2:22 w lp, 'NewtonsCradleSelfTest.stat' u 3:41 w l");
92 
93  StatisticsVector<Z> stats1("NewtonsCradleSelfTest");
94  stats1.setNZ(400);
95  stats1.setCGWidth(w);
96  stats1.setSuperExact(false);
97  stats1.setCGShape("Gaussian");
98  stats1.setCGTimeMin(problem.getTimeMax()*1.00000999999);
99  stats1.setTimeMaxStat(1e20);
100  //stats1.statFile.setName("NewtonsCradleSelfTest.old.stat");
101  logger(INFO,"Creating %",stats1.statFile.getName());
102  stats1.statistics_from_fstat_and_data();
103 
104  logger(INFO,"Test StatisticsVector for different CG functions (Gauss, Heaviside, Lucy)");
105  int i=0;
106  std::array<std::string,3> str = {"Gaussian","HeavisideSphere","Lucy"};
107 
108  for (int i=0; i<3; i++) {
109  double w=0.125;
110  if (i==1) w*=2;
111  if (i==2) w*=2*sqrt(3);
112 
113  StatisticsVector<Z> stats0("NewtonsCradleSelfTest");
114  stats0.setZMinStat(-0.5);
115  stats0.statFile.setName(stats0.getName() + "_" + str[i] + "Z.stat");
116  stats0.set_h(0.02);
117  stats0.verbose();
118  stats0.setCGWidth(w);
119  stats0.setSuperExact(true);
120  stats0.setCGShape(str[i].c_str());
121  stats0.setCGTimeMin(problem.getTimeMax()*.999999);
122  stats0.setTimeMaxStat(1e20);
123  logger(INFO,"Creating %",stats0.statFile.getName());
124  stats0.statistics_from_fstat_and_data();
125 
126  StatisticsVector<XYZ> stats2("NewtonsCradleSelfTest");
127  stats2.setZMinStat(-0.5);
128  stats2.statFile.setName(stats2.getName() + "_" + str[i] + "XYZ.stat");
129  stats2.set_h(0.02);
130  stats2.setNY(1);
131  stats2.setCGWidth(w);
132  stats2.setSuperExact(true);
133  stats2.setCGShape(str[i].c_str());
134  stats2.setCGTimeMin(problem.getTimeMax()*.999999);
135  stats2.setTimeMaxStat(1e20);
136  logger(INFO,"Creating %",stats2.statFile.getName());
137  stats2.statistics_from_fstat_and_data();
138 
139  }
140 
141  return(0);
142 }
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:11
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
RowVector3d w
Definition: Matrix_resize_int.cpp:3
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:360
void restartAndEvaluateDataFiles(const std::string &name, bool evaluateFStatFiles=true)
Definition: CGHandler.cc:173
void restartAndEvaluateRestartFiles(const std::string &name)
Definition: CGHandler.cc:167
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1479
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:16
Definition: NewtonsCradleSelfTest.cpp:14
This class is used to extract statistical data from MD simulations.
Definition: StatisticsVector.h:41
Evaluates time-averaged continuum fields and writes the data into a stat file.
Definition: TimeAveragedCG.h:39
Definition: Kernel/Math/Vector.h:30
#define INFO(i)
Definition: mumps_solver.h:54
str
Definition: compute_granudrum_aor.py:141
const Mdouble pi
Definition: ExtendedMath.h:23
bool writeToFile(const std::string &filename, const std::string &filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:29
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References DPMBase::cgHandler, BaseHandler< T >::copyAndAddObject(), e(), DPMBase::getName(), File::getName(), i, INFO, logger, constants::pi, problem, CGHandler::restartAndEvaluateDataFiles(), CGHandler::restartAndEvaluateRestartFiles(), StatisticsVector< T >::set_h(), StatisticsVector< T >::setCGShape(), StatisticsVector< T >::setCGTimeMin(), StatisticsVector< T >::setCGWidth(), File::setName(), StatisticsVector< T >::setNY(), StatisticsVector< T >::setNZ(), StatisticsVector< T >::setSuperExact(), StatisticsVector< T >::setTimeMaxStat(), StatisticsVector< T >::setZMinStat(), sqrt(), DPMBase::statFile, StatisticsVector< T >::statistics_from_fstat_and_data(), compute_granudrum_aor::str, StatisticsVector< T >::verbose(), w, and helpers::writeToFile().