15 " Testing getSaveCountFromNumberOfSavesAndTimeMaxAndTimeStep");
20 logger(
ERROR,
"save count is %, but should be %", saveCount, 501);
24 std::stringstream is(
"1.0\n2.000000000000001\n3.0");
25 std::stringstream
line;
36 if (
value != 2.000000000000001)
44 "0.5 0.5 0 0 0 0.5 0 0 0 0 0 0 0 0\n");
58 logger(
ERROR,
"HelperFunctionsUnitTest.ini exists, but is not detected");
63 logger(
ERROR,
"HelperFunctionsUnitTest.out does not exist, but is detected");
70 logger(
ERROR,
"effective mass is %, but should be %", effectiveMass, 2.0 / 3.0);
75 logger(
INFO,
" Testing removeFromCommandline");
76 char arguments[][20] = {
"programname",
"-test1",
"-test2",
"1"};
79 argvTest =
new char*[argcTest];
81 for (
unsigned int i=0;
i<argcTest;
i++)
83 argvTest[
i] = &arguments[
i][0];
90 logger(
ERROR,
"helpers::removeFromCommandline not working as expected");
94 logger(
VERBOSE,
"Running LinearViscoelasticSpecies helper functions unit test");
99 Mdouble realCollisionTime = 0.004971179385062563;
100 Mdouble realRestitution = 0.883132984295725;
101 Mdouble realMaximumVelocity = 316.227766016838;
112 logger(
ERROR,
"maximum velocity is %, but should be %", maximumVelocity, realMaximumVelocity);
115 logger(
VERBOSE,
" Testing getCollisionTime, getRestitutionCoefficient");
120 logger(
ERROR,
"collision time is %, but should be %", collisionTime, realCollisionTime);
124 logger(
ERROR,
"restitution coefficient is %, but should be %", restitution, realRestitution);
127 logger(
VERBOSE,
" Testing setStiffnessAndRestitutionCoefficient");
138 logger(
VERBOSE,
" Testing setCollisionTimeAndRestitutionCoefficient");
149 logger(
VERBOSE,
" Testing setCollisionTimeAndRestitutionCoefficient for two masses");
173 species2.
mixAll(&species0, &species1);
176 logger(
ERROR,
"stiffness is %, but should be %", species2.getStiffness(), realStiffness);
180 logger(
ERROR,
"dissipation is %, but should be %", species2.getDissipation(), realDissipation);
183 logger(
VERBOSE,
"Running LinearPlasticViscoelasticSpecies helper functions unit test");
187 species3.setPlasticParameters(realStiffness, 2.0 * realStiffness, 0.5 * realStiffness, 0.5);
190 logger(
ERROR,
"stiffness is %, but should be %", species3.getLoadingStiffness(), realStiffness);
194 logger(
ERROR,
"max. unloading stiffness is %, but should be %", species3.getUnloadingStiffnessMax(),
195 2.0 * realStiffness);
199 logger(
ERROR,
"max. unloading stiffness is %, but should be %", species3.getCohesionStiffness(),
200 0.5 * realStiffness);
204 logger(
ERROR,
"dissipation is %, but should be %", species3.getPenetrationDepthMax(), 0.5);
207 logger(
VERBOSE,
" Testing setCollisionTimeAndRestitutionCoefficient");
208 species3.setCollisionTimeAndRestitutionCoefficient(realCollisionTime, realRestitution, mass);
211 logger(
ERROR,
"stiffness is %, but should be %", species3.getLoadingStiffness(), realStiffness);
215 logger(
ERROR,
"max. unloading stiffness is %, but should be %", species3.getUnloadingStiffnessMax(),
220 logger(
ERROR,
"dissipation is %, but should be %", species3.getDissipation(), realDissipation);
224 Mdouble timeStep = species3.computeTimeStep(mass);
227 logger(
ERROR,
"time step is %, but should be %", timeStep, 0.02 * realCollisionTime);
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
LL< Log::VERBOSE > VERBOSE
Verbose information.
Definition: Logger.cc:36
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:32
void setStiffnessAndRestitutionCoefficient(Mdouble k_, Mdouble eps, Mdouble mass)
Sets k, disp such that it matches a given tc and eps for a collision of two copies of P.
Definition: LinearViscoelasticNormalSpecies.cc:165
Mdouble getMaximumVelocity(Mdouble radius, Mdouble mass) const
Calculates the maximum velocity allowed for a collision of two copies of P (for higher velocities par...
Definition: LinearViscoelasticNormalSpecies.cc:154
Mdouble getStiffness() const
Allows the spring constant to be accessed.
Definition: LinearViscoelasticNormalSpecies.cc:83
Mdouble getCollisionTime(Mdouble mass) const
Calculates collision time for two copies of a particle of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:116
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:96
void setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, BaseParticle *p)
Sets k, disp such that it matches a given tc and eps for a collision of two copies of particle p.
Definition: LinearViscoelasticNormalSpecies.cc:191
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
Definition: LinearViscoelasticNormalSpecies.cc:109
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:72
Mdouble getRestitutionCoefficient(Mdouble mass) const
Calculates restitution coefficient for two copies of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:147
Contains contact force properties for contacts between particles with two different species.
Definition: MixedSpecies.h:22
void mixAll(BaseSpecies *const S, BaseSpecies *const T) final
sets the MixedSpecies properties by mixing the properties of two particle species
Definition: MixedSpecies.h:277
#define INFO(i)
Definition: mumps_solver.h:54
squared absolute value
Definition: GlobalFunctions.h:87
line
Definition: calibrate.py:103
unsigned int getSaveCountFromNumberOfSavesAndTimeMaxAndTimeStep(unsigned int numberOfSaves, Mdouble timeMax, Mdouble timeStep)
Returns the correct saveCount if the total number of saves, the final time and the time step is known...
Definition: FormulaHelpers.cc:75
bool removeFromCommandline(int &argc, char *argv[], const std::string &varName, int nArgs)
May be used to hide arguments from argc and argv.
Definition: CommandLineHelpers.cc:41
bool fileExists(const std::string &strFilename)
Function to check if a file exists, is used to check if a run has already need done.
Definition: FileIOHelpers.cc:77
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in.
Definition: StringHelpers.cc:41
bool openFile(std::fstream &file, const std::string &filename, std::fstream::openmode mode)
Provides a simple interface for opening a file.
Definition: FileIOHelpers.cc:115
bool readFromCommandLine(int argc, char *argv[], const std::string &varName)
Returns true if command line arguments contain varName, false else.
Definition: CommandLineHelpers.cc:99
Mdouble getEffectiveMass(Mdouble mass0, Mdouble mass1)
Calculates the effective mass of a particle pair, i.e. half the harmonic mean of two particle masses.
Definition: FormulaHelpers.cc:15
bool writeToFile(const std::string &filename, const std::string &filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:29
bool isEqual(Mdouble v1, Mdouble v2, Mdouble absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
Definition: ExtendedMath.cc:230