MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NewtonsCradleSelfTest.cpp File Reference
#include "Mercury3D.h"
#include "StatisticsVector.h"
#include "Particles/BaseParticle.h"
#include "Walls/InfiniteWall.h"
#include <cmath>
#include <iostream>
#include <iomanip>
#include <Species/LinearViscoelasticSpecies.h>

Go to the source code of this file.

Classes

class  NewtonsCradleSelfTest
 

Functions

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

Function Documentation

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

Definition at line 76 of file NewtonsCradleSelfTest.cpp.

References BaseHandler< T >::copyAndAddObject(), Files::getName(), DPMBase::getTimeMax(), NewtonsCradleSelfTest::N, constants::pi, StatisticsVector< T >::set_h(), StatisticsVector< T >::setCGShape(), StatisticsVector< T >::setCGTimeMin(), StatisticsVector< T >::setCGWidth(), DPMBase::setGravity(), File::setName(), Files::setName(), StatisticsVector< T >::setNY(), DPMBase::setParticleDimensions(), Files::setSaveCount(), StatisticsVector< T >::setSuperExact(), DPMBase::setSystemDimensions(), DPMBase::setTimeMax(), StatisticsVector< T >::setTimeMaxStat(), DPMBase::setTimeStep(), StatisticsVector< T >::setXMaxStat(), StatisticsVector< T >::setXMinStat(), StatisticsVector< T >::setYMaxStat(), StatisticsVector< T >::setYMinStat(), StatisticsVector< T >::setZMaxStat(), StatisticsVector< T >::setZMinStat(), DPMBase::solve(), DPMBase::speciesHandler, Files::statFile, and StatisticsVector< T >::statistics_from_fstat_and_data().

77 {
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./constants::pi/8*(2*problem.N+.5)*1.05*1.05);
85  problem.setGravity(Vec3D(0.,0.,-1.));
86  species->setCollisionTimeAndRestitutionCoefficient(.01,.1,1.);
87  problem.setTimeStep(.0001);
88  problem.setTimeMax(8.0);
89  problem.setSaveCount(1000);
90  std::cout << "Relax the packing" << std::endl;
91  problem.solve();
92 
93  std::cout << "Get statistics" << std::endl;
94  std::string str[3];
95  str[0]="Gaussian";
96  str[1]="HeavisideSphere";
97  str[2]="Lucy";
98 
99  int i=0;
100  double w=0.46/3.;
101  StatisticsVector<Z> stats1("NewtonsCradleSelfTest");
102  stats1.setZMinStat(-.5);
103  stats1.setZMaxStat(2*problem.N);
104  stats1.setXMinStat(0.5);
105  stats1.setXMaxStat(1.55);
106  stats1.setYMinStat(0.5);
107  stats1.setYMaxStat(1.55);
108  std::cout << stats1.getName() + "_" + str[i] + "T_XYZ.stat" << std::endl;
109  stats1.statFile.setName(stats1.getName() + "_" + str[i] + "T_XYZ.stat");
110  stats1.set_h(0.0005);
111  stats1.setCGWidth(w);
112  stats1.setSuperExact(false);
113  stats1.setCGShape(str[i].c_str());
114  stats1.setCGTimeMin(problem.getTimeMax()*1.00000999999);
115  stats1.setTimeMaxStat(1e20);
116  stats1.statistics_from_fstat_and_data();
117 
118  for (int i=0; i<3; i++) {
119  double w=0.125;
120  if (i==1) w*=2;
121  if (i==2) w*=2*sqrt(3);
122 
123  StatisticsVector<Z> stats0("NewtonsCradleSelfTest");
124  stats0.setZMinStat(-0.5);
125  stats0.statFile.setName(stats0.getName() + "_" + str[i] + "T_XYZ.stat");
126  stats0.set_h(0.02);
127  stats0.setCGWidth(w);
128  stats0.setSuperExact(true);
129  stats0.setCGShape(str[i].c_str());
130  stats0.setCGTimeMin(problem.getTimeMax()*.999999);
131  stats0.setTimeMaxStat(1e20);
132  stats0.statistics_from_fstat_and_data();
133 
134  StatisticsVector<XYZ> stats2("NewtonsCradleSelfTest");
135  stats2.setZMinStat(-0.5);
136  stats2.statFile.setName(stats2.getName() + "_" + str[i] + "T_XYZ.stat");
137  stats2.set_h(0.02);
138  stats2.setNY(1);
139  stats2.setCGWidth(w);
140  stats2.setSuperExact(true);
141  stats2.setCGShape(str[i].c_str());
142  stats2.setCGTimeMin(problem.getTimeMax()*.999999);
143  stats2.setTimeMaxStat(1e20);
144  stats2.statistics_from_fstat_and_data();
145 
146  /* Current the 2D statistics is not implement this tets will be added when it is.
147  StatisticsVector<XZ> stats1("NewtonsCradleSelfTest");
148  stats1.setZMinStat(-0.5);
149  stats1.statFile.setName(str[i] + "T_XZ.stat");
150  stats1.set_h(0.02);
151  stats1.setCGWidth(w);
152  stats1.setSuperExact(true);
153  stats1.setCGShape(str[i].c_str());
154  stats1.setCGTimeMin(problem.getTimeMax()*.999999);
155  stats1.setTimeMaxStat(1e20);
156  stats1.statistics_from_fstat_and_data();
157  */
158  // should give you Density 5
159  }
160 
161  return(0);
162 }
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
void setParticleDimensions(unsigned int particleDimensions)
Allows the dimension of the particle (f.e. for mass) to be changed. e.g. discs or spheres...
Definition: DPMBase.cc:474
void setSystemDimensions(unsigned int newDim)
Allows for the dimension of the simulation to be changed.
Definition: DPMBase.cc:453
void setGravity(Vec3D newGravity)
Allows to modify the gravity vector.
Definition: DPMBase.cc:431
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:268
const Mdouble pi
Definition: ExtendedMath.h:42
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
This class is used to extract statistical data from MD simulations.
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble getTimeMax() const
Allows the user to access the total simulation time during the simulation. Cannot change it though...
Definition: DPMBase.cc:194