ForceSelfTest.cpp File Reference

Classes

class  ParticleParticleCollision
 
class  WallParticleCollision
 

Functions

void particleParticleTest ()
 
void wallParticleTest ()
 
int main ()
 

Function Documentation

◆ main()

int main ( )
351 {
352 
353  logger(INFO, "\nnote: analytic values are only asymptotically correct as delta->0");
356  return 0;
357 }
void wallParticleTest()
Definition: ForceSelfTest.cpp:268
void particleParticleTest()
Definition: ForceSelfTest.cpp:186
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.

References INFO, logger, particleParticleTest(), and wallParticleTest().

◆ particleParticleTest()

void particleParticleTest ( )
187 {
188  logger(INFO, "\ntesting particle-particle collisions ...\n\n", Flusher::NO_FLUSH);
189 
191 
192  problem.random.setRandomSeed(5);
193 
194  problem.setupInitialConditions();
195  Mdouble normalRelativeVelocity, tangentialRelativeVelocity, analyticTangentialRelativeVelocity;
196 
197  logger(INFO, "5: without tangential forces");
198  problem.setName("ForceSelfTest5");
199  problem.solve();
200  problem.getRelativeVelocityComponents(normalRelativeVelocity, tangentialRelativeVelocity);
201  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
202  problem.initialTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
203  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
204  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
205 
206  //problem.setAppend_to_files(true);
207 
208  logger(INFO, "6: with Coulomb friction");
209  Mdouble mu = problem.random.getRandomNumber(0.0, 1.0);
210  problem.species->setSlidingFrictionCoefficient(mu);
211  problem.species->setSlidingDissipation(1e20);
212  //problem.species->setSlidingStiffness(0.0);
213  problem.setName("ForceSelfTest6");
214  problem.solve();
215  problem.getRelativeVelocityComponents(normalRelativeVelocity, tangentialRelativeVelocity);
216  analyticTangentialRelativeVelocity = std::max(0.0, problem.initialTangentialRelativeVelocity +
217  mu * 3.5 * (1 + problem.en) *
219  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
220  analyticTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
221  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
222  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
223 
224  logger(INFO, "7: with Coulomb friction, spring activated");
225  problem.species->setSlidingStiffness(1.0);
226  //problem.species->setSlidingDissipation(1);
227  problem.setName("ForceSelfTest7");
228  problem.solve();
229  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
230  analyticTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
231  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
232  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
233 
234  logger(INFO, "8: with tangential viscous force");
235  Mdouble et = problem.random.getRandomNumber(-1.0, 0.0);
236  problem.species->setSlidingFrictionCoefficient(1e20);
237  problem.species->setSlidingDissipation(-log(-et) / (2.0 * problem.tc) / 3.5 * 2.0 * problem.m12);
238  problem.species->setSlidingStiffness(0.0);
239  problem.setName("ForceSelfTest8");
240  problem.solve();
241  problem.getRelativeVelocityComponents(normalRelativeVelocity, tangentialRelativeVelocity);
242  analyticTangentialRelativeVelocity = problem.initialTangentialRelativeVelocity *
243  exp(-2.0 * 3.5 * problem.species->getSlidingDissipation() /
244  (2.0 * problem.m12) * problem.getCollisionTime(2.0 * problem.m12));
245  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
246  analyticTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
247  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
248  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
249 
250  logger(INFO, "9: with tangential elastic force");
251  Mdouble et2 = problem.random.getRandomNumber(0.0, 1.0);
252  problem.species->setSlidingFrictionCoefficient(1e20);
253  problem.species->setSlidingDissipation(0.0);
254  problem.species->setSlidingStiffness(
255  problem.species->getStiffness() / 3.5 * mathsFunc::square(acos(-et2) / constants::pi));
256  problem.setName("ForceSelfTest9");
257  problem.solve();
258  problem.getRelativeVelocityComponents(normalRelativeVelocity, tangentialRelativeVelocity);
259  analyticTangentialRelativeVelocity = problem.initialTangentialRelativeVelocity *
260  cos(sqrt(problem.species->getSlidingStiffness() / problem.m12 * 3.5) *
261  problem.getCollisionTime(2.0 * problem.m12));
262  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
263  analyticTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
264  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
265  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
266 }
double Mdouble
Definition: GeneralDefine.h:34
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
RNG random
This is a random generator, often used for setting up the initial conditions etc.....
Definition: DPMBase.h:1432
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
Definition: ForceSelfTest.cpp:33
Mdouble initialNormalRelativeVelocity
Definition: ForceSelfTest.cpp:114
Mdouble m12
Definition: ForceSelfTest.cpp:117
LinearViscoelasticSlidingFrictionSpecies * species
Definition: ForceSelfTest.cpp:118
Mdouble tc
Definition: ForceSelfTest.cpp:116
Mdouble initialTangentialRelativeVelocity
Definition: ForceSelfTest.cpp:114
void getRelativeVelocityComponents(Mdouble &normalRelativeVelocity, Mdouble &tangentialRelativeVelocity)
Definition: ForceSelfTest.cpp:102
Mdouble en
Definition: ForceSelfTest.cpp:116
Mdouble getCollisionTime(Mdouble mass)
Calculates collision time for two copies of a particle of species 0.
Definition: ForceSelfTest.cpp:109
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: ForceSelfTest.cpp:44
void setRandomSeed(unsigned long int new_seed)
This is the seed for the random number generator (note the call to seed_LFG is only required really i...
Definition: RNG.cc:53
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
const Mdouble pi
Definition: ExtendedMath.h:45
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:104
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
T square(const T val)
squares a number
Definition: ExtendedMath.h:106
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84

References mathsFunc::cos(), ParticleParticleCollision::en, mathsFunc::exp(), ParticleParticleCollision::getCollisionTime(), RNG::getRandomNumber(), ParticleParticleCollision::getRelativeVelocityComponents(), INFO, ParticleParticleCollision::initialNormalRelativeVelocity, ParticleParticleCollision::initialTangentialRelativeVelocity, mathsFunc::log(), logger, ParticleParticleCollision::m12, NO_FLUSH, constants::pi, DPMBase::random, DPMBase::setName(), RNG::setRandomSeed(), ParticleParticleCollision::setupInitialConditions(), DPMBase::solve(), ParticleParticleCollision::species, mathsFunc::square(), and ParticleParticleCollision::tc.

Referenced by main().

◆ wallParticleTest()

void wallParticleTest ( )
269 {
270  logger(INFO, "\ntesting wall-particle collisions ...\n");
271 
272  srand(5);
273 
274  WallParticleCollision problem;
275  problem.setupInitialConditions();
276 
277  Mdouble normalRelativeVelocity, tangentialRelativeVelocity, analyticTangentialRelativeVelocity;
278 
279  //problem.setAppend_to_files(true);
280 
281  logger(INFO, "0: without tangential forces");
282  problem.setName("ForceSelfTest0");
283  problem.solve();
284 
285  problem.getRelativeVelocityComponents(normalRelativeVelocity, tangentialRelativeVelocity);
286  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
287  problem.initialTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
288  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
289  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
290 
291  logger(INFO, "1: with Coulomb friction");
292  Mdouble mu = problem.random.getRandomNumber(0.0, 1.0);
293  problem.species->setSlidingFrictionCoefficient(mu);
294  problem.species->setSlidingDissipation(1e20);
295  problem.species->setSlidingStiffness(0.0);
296  problem.setName("ForceSelfTest1");
297  problem.solve();
298  problem.getRelativeVelocityComponents(normalRelativeVelocity, tangentialRelativeVelocity);
299  analyticTangentialRelativeVelocity = std::max(0.0, problem.initialTangentialRelativeVelocity +
300  mu * 3.5 * (1 + problem.en) *
302  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
303  analyticTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
304  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
305  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
306 
307  logger(INFO, "2: with Coulomb friction, spring activated");
308  problem.species->setSlidingStiffness(1.0);
309  problem.setName("ForceSelfTest2");
310  problem.solve();
311  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
312  problem.initialTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
313  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
314  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
315 
316  logger(INFO, "3: with tangential viscous force");
317  Mdouble et = problem.random.getRandomNumber(-1.0, 0.0);
318  problem.species->setSlidingFrictionCoefficient(1e20);
319  problem.species->setSlidingDissipation(-log(-et) / (2.0 * problem.tc) / 3.5 * 2.0 * problem.m12);
320  problem.species->setSlidingStiffness(0.0);
321  problem.setName("ForceSelfTest3");
322  problem.solve();
323  problem.getRelativeVelocityComponents(normalRelativeVelocity, tangentialRelativeVelocity);
324  analyticTangentialRelativeVelocity = problem.initialTangentialRelativeVelocity *
325  exp(-2.0 * 3.5 * problem.species->getSlidingDissipation() /
326  (2.0 * problem.m12) * problem.getCollisionTime(2.0 * problem.m12));
327  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
328  problem.initialTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
329  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
330  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
331 
332  logger(INFO, "4: with tangential elastic force");
333  Mdouble et2 = problem.random.getRandomNumber(0.0, 1.0);
334  problem.species->setSlidingFrictionCoefficient(1e20);
335  problem.species->setSlidingDissipation(0.0);
336  problem.species->setSlidingStiffness(
337  problem.species->getStiffness() / 3.5 * mathsFunc::square(acos(-et2) / constants::pi));
338  problem.setName("ForceSelfTest4");
339  problem.solve();
340  problem.getRelativeVelocityComponents(normalRelativeVelocity, tangentialRelativeVelocity);
341  analyticTangentialRelativeVelocity = problem.initialTangentialRelativeVelocity *
342  cos(sqrt(problem.species->getSlidingStiffness() / problem.m12 * 3.5) *
343  problem.getCollisionTime(2.0 * problem.m12));
344  logger(INFO, "tangentialRelativeVelocity: analytic=%, simulation=%\n",
345  problem.initialTangentialRelativeVelocity, tangentialRelativeVelocity, Flusher::NO_FLUSH);
346  logger(INFO, "normalRelativeVelocity: analytic=%, simulation=%",
347  -problem.en * problem.initialNormalRelativeVelocity, normalRelativeVelocity);
348 }
Definition: ForceSelfTest.cpp:121
void getRelativeVelocityComponents(Mdouble &normalRelativeVelocity, Mdouble &tangentialRelativeVelocity)
Definition: ForceSelfTest.cpp:178
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: ForceSelfTest.cpp:124

References mathsFunc::cos(), ParticleParticleCollision::en, mathsFunc::exp(), ParticleParticleCollision::getCollisionTime(), RNG::getRandomNumber(), WallParticleCollision::getRelativeVelocityComponents(), INFO, ParticleParticleCollision::initialNormalRelativeVelocity, ParticleParticleCollision::initialTangentialRelativeVelocity, mathsFunc::log(), logger, ParticleParticleCollision::m12, NO_FLUSH, constants::pi, DPMBase::random, DPMBase::setName(), WallParticleCollision::setupInitialConditions(), DPMBase::solve(), ParticleParticleCollision::species, mathsFunc::square(), and ParticleParticleCollision::tc.

Referenced by main().