HertzianSinterForceUnitTest.cpp File Reference
#include "DPMBase.h"
#include <Species/HertzianSinterSpecies.h>
#include <Logger.h>

Classes

class  HertzianSinterForceUnitTest
 This code tests our plastic force model, as published in Luding 2008. More...
 
class  LongHertzianSinterForceUnitTest
 

Functions

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

Function Documentation

◆ main()

int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)
117 {
119  double k1=100.0;
120  sf.species->setPlasticParameters(k1, 10.0*k1, k1, 1.0);
121  sf.species->setDissipation(0);
122  sf.setParticleDimensions(3);
123  sf.setSystemDimensions(3);
124 
125  logger(INFO,"Testing particle particles collision for elastic plastic forces. \n"
126  "This will be done for several values of scaled relative velocity chi");
127 
128  //sf.restartFile.getFstream().precision(20);
129 
130  //Set up constant data that will be used
131  const std::vector<double> chi = {0.34, 0.69, 1.1, 1.37};
132  const std::vector<Vec3D> leftFinalVecloity = {
133  Vec3D(-0.032721738352012,0.0,0.0),
134  Vec3D(-0.0138683231953154,0.0,0.0),
135  Vec3D(-0.0204655358555405,0.0,0.0),
136  Vec3D(-0.163049415300304,0.0,0.0)};
137  const std::vector<Vec3D> leftFinalPosition = {
138  Vec3D(0.995546292935715,1.0,1.0),
139  Vec3D(1.00695193269955,1.0,1.0),
140  Vec3D(1.00840467123501,1.0,1.0),
141  Vec3D(0.969386085767181,1.0,1.0)};
142 
143  //Loop over all test cases
144  for (int i=0; i<4; i++)
145  {
146  logger(INFO, "Running for chi=%", chi[i]);
147  sf.set_chi(chi[i]);
148  std::stringstream ss("");
149  ss << "HertzianSinterForceUnitTest" << sf.get_chi();
150  sf.setName(ss.str().c_str());
151  sf.solve();
152  sf.writeRestartFile();
153 
154 // //Now check the particles are in the right place for each of the 4 cases
155 // auto pIt = sf.particleHandler.begin();
156 // if (!(*pIt)->getPosition().isEqualTo(leftFinalPosition[i], 1e-10))
157 // logger(FATAL,"Left particle is in the wrong position. It is at % and should be %",(*pIt)->getPosition(),leftFinalPosition[i]);
158 // if (!(*pIt)->getVelocity().isEqualTo(leftFinalVecloity[i] , 1e-10))
159 // logger(FATAL,"Left particle has the wrong velocity. It is at % and should be %",(*pIt)->getVelocity(),leftFinalVecloity[i]);
160  }
161 
162  //A longer simulation, with sintering activated
164  lsf.species->setPlasticParameters(k1, 10.0*k1, k1, 1.0);
165  lsf.species->setSinterRate(1e-3);
166  lsf.species->setDissipation(2e-1);
167  lsf.setParticleDimensions(3);
168  lsf.setSystemDimensions(3);
169  logger(INFO, "Running longer");
170  lsf.set_chi(0.47);
171  lsf.setName("LongHertzianSinterForceUnitTest");
172  lsf.solve();
173  lsf.writeRestartFile();
174 
175 
176 
177  //(1-((k1+kc)/k2)^1.5) / (1-(k1/k2)^1.5)
178 
179  logger(INFO,"Execute 'gnuplot HertzianSinterForceUnitTest.gnu' to view "
180  "output");
181  helpers::writeToFile("HertzianSinterForceUnitTest.gnu",
182  "set xlabel 'displacement'\n"
183  "set ylabel 'force'\n"
184  "plot 'HertzianSinterForceUnitTest1.1.fstat' u 7:9, 4./3.*100*x**1.5, 4./3.*1000*(x-0.1)**1.5-4./3.*100*x**1.5, -4./3.*100*x**1.5/(x<0.1)\n"
185  );
186 
187  logger(INFO,"Execute 'gnuplot LongHertzianSinterForceUnitTest.gnu' to view "
188  "output");
189  helpers::writeToFile("LongHertzianSinterForceUnitTest.gnu",
190  "set xlabel 'time'\n"
191  "set ylabel 'displacement'\n"
192  //"plot 'LongHertzianSinterForceUnitTest1.1.fstat' u 7:9 w lp\n"
193  "plot 'LongHertzianSinterForceUnitTest.fstat' u 1:7, sqrt(0.001*(x+120))\n"
194  );
195 }
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.
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
virtual void writeRestartFile()
Stores all the particle data for current save time step to a "restart" file, which is a file simply i...
Definition: DPMBase.cc:2942
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
This code tests our plastic force model, as published in Luding 2008.
Definition: HertzianSinterForceUnitTest.cpp:33
HertzianSinterSpecies * species
Definition: HertzianSinterForceUnitTest.cpp:89
double get_chi()
Definition: HertzianSinterForceUnitTest.cpp:86
void set_chi(double new_)
Definition: HertzianSinterForceUnitTest.cpp:85
Definition: HertzianSinterForceUnitTest.cpp:93
Definition: Vector.h:51
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 HertzianSinterForceUnitTest::get_chi(), constants::i, INFO, logger, HertzianSinterForceUnitTest::set_chi(), DPMBase::setName(), DPMBase::setParticleDimensions(), DPMBase::setSystemDimensions(), DPMBase::solve(), HertzianSinterForceUnitTest::species, DPMBase::writeRestartFile(), and helpers::writeToFile().