36 " Testing getSaveCountFromNumberOfSavesAndTimeMaxAndTimeStep");
41 logger(
ERROR,
"save count is %, but should be %", saveCount, 501);
45 std::stringstream is(
"1.0\n2.000000000000001\n3.0");
46 std::stringstream line;
49 line >> value >> value;
52 logger(
ERROR,
"value is %, but should be %", value, 0.0);
57 if (value != 2.000000000000001)
59 logger(
ERROR,
"value is %, but should be %", value, 2.000000000000001);
65 "0.5 0.5 0 0 0 0.5 0 0 0 0 0 0 0 0\n");
72 logger(
ERROR,
"value is %, but should be %", value, 1.0);
79 logger(
ERROR,
"HelperFunctionsUnitTest.ini exists, but is not detected");
84 logger(
ERROR,
"HelperFunctionsUnitTest.out does not exist, but is detected");
91 logger(
ERROR,
"effective mass is %, but should be %", effectiveMass, 2.0 / 3.0);
96 logger(
INFO,
" Testing removeFromCommandline");
97 char arguments[][20] = {
"programname",
"-test1",
"-test2",
"1"};
100 argvTest =
new char*[argcTest];
102 for (
unsigned int i=0;
i<argcTest;
i++)
104 argvTest[
i] = &arguments[
i][0];
111 logger(
ERROR,
"helpers::removeFromCommandline not working as expected");
115 logger(
VERBOSE,
"Running LinearViscoelasticSpecies helper functions unit test");
117 Mdouble realDissipation = 25.0;
120 Mdouble realCollisionTime = 0.004971179385062563;
121 Mdouble realRestitution = 0.883132984295725;
122 Mdouble realMaximumVelocity = 316.227766016838;
133 logger(
ERROR,
"maximum velocity is %, but should be %", maximumVelocity, realMaximumVelocity);
136 logger(
VERBOSE,
" Testing getCollisionTime, getRestitutionCoefficient");
141 logger(
ERROR,
"collision time is %, but should be %", collisionTime, realCollisionTime);
145 logger(
ERROR,
"restitution coefficient is %, but should be %", restitution, realRestitution);
148 logger(
VERBOSE,
" Testing setStiffnessAndRestitutionCoefficient");
159 logger(
VERBOSE,
" Testing setCollisionTimeAndRestitutionCoefficient");
170 logger(
VERBOSE,
" Testing setCollisionTimeAndRestitutionCoefficient for two masses");
194 species2.
mixAll(&species0, &species1);
197 logger(
ERROR,
"stiffness is %, but should be %", species2.getStiffness(), realStiffness);
201 logger(
ERROR,
"dissipation is %, but should be %", species2.getDissipation(), realDissipation);
204 logger(
VERBOSE,
"Running LinearPlasticViscoelasticSpecies helper functions unit test");
208 species3.setPlasticParameters(realStiffness, 2.0 * realStiffness, 0.5 * realStiffness, 0.5);
211 logger(
ERROR,
"stiffness is %, but should be %", species3.getLoadingStiffness(), realStiffness);
213 if (!
mathsFunc::isEqual(species3.getUnloadingStiffnessMax(), 2.0 * realStiffness, 1e-10))
215 logger(
ERROR,
"max. unloading stiffness is %, but should be %", species3.getUnloadingStiffnessMax(),
216 2.0 * realStiffness);
220 logger(
ERROR,
"max. unloading stiffness is %, but should be %", species3.getCohesionStiffness(),
221 0.5 * realStiffness);
225 logger(
ERROR,
"dissipation is %, but should be %", species3.getPenetrationDepthMax(), 0.5);
228 logger(
VERBOSE,
" Testing setCollisionTimeAndRestitutionCoefficient");
229 species3.setCollisionTimeAndRestitutionCoefficient(realCollisionTime, realRestitution, mass);
232 logger(
ERROR,
"stiffness is %, but should be %", species3.getLoadingStiffness(), realStiffness);
236 logger(
ERROR,
"max. unloading stiffness is %, but should be %", species3.getUnloadingStiffnessMax(),
241 logger(
ERROR,
"dissipation is %, but should be %", species3.getDissipation(), realDissipation);
245 Mdouble timeStep = species3.computeTimeStep(mass);
248 logger(
ERROR,
"time step is %, but should be %", timeStep, 0.02 * realCollisionTime);
double Mdouble
Definition: GeneralDefine.h:34
LL< Log::VERBOSE > VERBOSE
Verbose information.
Definition: Logger.cc:57
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.
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
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:186
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:175
Mdouble getStiffness() const
Allows the spring constant to be accessed.
Definition: LinearViscoelasticNormalSpecies.cc:104
Mdouble getCollisionTime(Mdouble mass) const
Calculates collision time for two copies of a particle of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:137
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:117
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:212
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
Definition: LinearViscoelasticNormalSpecies.cc:130
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:93
Mdouble getRestitutionCoefficient(Mdouble mass) const
Calculates restitution coefficient for two copies of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:168
Contains contact force properties for contacts between particles with two different species.
Definition: MixedSpecies.h:43
void mixAll(BaseSpecies *const S, BaseSpecies *const T) final
sets the MixedSpecies properties by mixing the properties of two particle species
Definition: MixedSpecies.h:290
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
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:96
bool openFile(std::fstream &file, std::string filename, std::fstream::openmode mode)
Provides a simple interface for opening a file.
Definition: FileIOHelpers.cc:145
bool readFromCommandLine(int argc, char *argv[], std::string varName)
Returns true if command line arguments contain varName, false else.
Definition: CommandLineHelpers.cc:103
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:62
bool removeFromCommandline(int &argc, char *argv[], std::string varName, int nArgs)
May be used to hide arguments from argc and argv.
Definition: CommandLineHelpers.cc:43
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:36
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58
bool fileExists(std::string strFilename)
Function to check if a file exists, is used to check if a run has already need done.
Definition: FileIOHelpers.cc:107
bool isEqual(Mdouble v1, Mdouble v2, Mdouble absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
Definition: ExtendedMath.cc:251