45 std::cerr <<
"Error in helpers::computeCollisionTimeFromKandDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) stiffness is not set or has an unexpected value, (stiffness=" << k <<
")" << std::endl;
50 std::cerr <<
"Error in helpers::computeCollisionTimeFromKandDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) dissipation is not set or has an unexpected value, (dissipation=" << disp <<
")" << std::endl;
55 std::cerr <<
"Error in helpers::computeCollisionTimeFromKandDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
60 std::cerr <<
"Error in helpers::computeCollisionTimeFromKandDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) values for stiffness, dissipation and mass lead to an overdamped system (stiffness=" << k <<
" dissipation=" << disp <<
" mass=" << mass <<
")" << std::endl;
70 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromKandDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) stiffness is not set or has an unexpected value, (stiffness=" << k <<
")" << std::endl;
75 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromKandDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) dissipation is not set or has an unexpected value, (dissipation=" << disp <<
")" << std::endl;
80 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromKandDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
85 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromKandDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) values for stiffness, dissipation and mass lead to an overdamped system (stiffness=" << k <<
" dissipation=" << disp <<
" mass=" << mass <<
")" << std::endl;
95 std::cerr <<
"Error in helpers::computeDispFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass) stiffness is not set or has an unexpected value, (stiffness=" << k <<
")" << std::endl;
100 std::cerr <<
"Error in helpers::computeDispFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass) restitution coefficient is not set or has an unexpected value, (restitution coefficient=" << r <<
")" << std::endl;
105 std::cerr <<
"Error in helpers::computeDispFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
115 std::cerr <<
"Error in helpers::computeCollisionTimeFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass) stiffness is not set or has an unexpected value, (stiffness=" << k <<
")" << std::endl;
120 std::cerr <<
"Error in helpers::computeCollisionTimeFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass) restitution coefficient is not set or has an unexpected value, (restitution coefficient=" << r <<
")" << std::endl;
125 std::cerr <<
"Error in helpers::computeCollisionTimeFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
135 std::cerr <<
"Error in helpers::computeDispFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass) stiffness is not set or has an unexpected value, (stiffness=" << k <<
")" << std::endl;
140 std::cerr <<
"Error in helpers::computeDispFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass) collision time is not set or has an unexpected value, (collision time=" << tc <<
")" << std::endl;
145 std::cerr <<
"Error in helpers::computeDispFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
150 std::cerr <<
"Error in helpers::computeDispFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) values for stiffness, collision time and mass lead to an overdamped system (stiffness=" << k <<
" collision time=" << tc <<
" mass=" << mass <<
")" << std::endl;
160 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass) stiffness is not set or has an unexpected value, (stiffness=" << k <<
")" << std::endl;
165 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass) collision time is not set or has an unexpected value, (collision time=" << tc <<
")" << std::endl;
170 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
175 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass) values for stiffness, collision time and mass lead to an overdamped system (stiffness=" << k <<
" collision time=" << tc <<
" mass=" << mass <<
")" << std::endl;
185 std::cerr <<
"Error in helpers::computeDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass) collision time is not set or has an unexpected value, (collision time=" << tc <<
")" << std::endl;
190 std::cerr <<
"Error in helpers::computeDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass) restitution coefficient not set or has an unexpected value, (restitution coefficient=" << r <<
")" << std::endl;
195 std::cerr <<
"Error in helpers::computeDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
198 return -2.0 * mass * std::log(r) / tc;
205 std::cerr <<
"Error in helpers::computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass) collision time is not set or has an unexpected value, (collision time=" << tc <<
")" << std::endl;
210 std::cerr <<
"Error in helpers::computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass) restitution coefficient not set or has an unexpected value, (restitution coefficient=" << r <<
")" << std::endl;
215 std::cerr <<
"Error in helpers::computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
225 std::cerr <<
"Error in helpers::computeKFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass) collision time is not set or has an unexpected value, (collision time=" << tc <<
")" << std::endl;
230 std::cerr <<
"Error in helpers::computeKFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass) dissipation not set or has an unexpected value, (dissipation=" << disp <<
")" << std::endl;
235 std::cerr <<
"Error in helpers::computeKFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
245 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass) collision time is not set or has an unexpected value, (collision time=" << tc <<
")" << std::endl;
250 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass) dissipation not set or has an unexpected value, (dissipation=" << disp <<
")" << std::endl;
255 std::cerr <<
"Error in helpers::computeRestitutionCoefficientFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
258 return std::exp(-0.5 * disp * tc / mass);
265 std::cerr <<
"Error in helpers::computeKFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass) dissipation is not set or has an unexpected value, (dissipation time=" << disp <<
")" << std::endl;
270 std::cerr <<
"Error in helpers::computeKFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass) restitution coefficient not set or has an unexpected value, (restitution coefficient=" << r <<
")" << std::endl;
275 std::cerr <<
"Error in helpers::computeKFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
285 std::cerr <<
"Error in helpers::computeCollisionTimeFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass) dissipation is not set or has an unexpected value, (dissipation time=" << disp <<
")" << std::endl;
290 std::cerr <<
"Error in helpers::computeCollisionTimeFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass) restitution coefficient not set or has an unexpected value, (restitution coefficient=" << r <<
")" << std::endl;
295 std::cerr <<
"Error in helpers::computeCollisionTimeFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass) mass is not set or has an unexpected value (mass=" << mass <<
")" << std::endl;
298 return -2.0 * mass * std::log(r) / disp;
305 ans.
disp = -2.0 * mass * log(r) / tc;
311 ans.
dispt = 2. * sqrt(1.0 / 7.0 * mass * ans.
kt);
324 Mdouble DispCorrection = exp(-disp / mass / w) * asin(w / w0);
326 return radius * sqrt(8.0 * k / mass) / DispCorrection;
345 if (numberOfSaves > 0 && timeMax > 0 && timestep > 0)
347 return static_cast<unsigned int>(ceil((timeMax + timestep) / timestep / static_cast<double>(numberOfSaves - 1)));
351 logger(
ERROR,
"[Helpers::getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep()] numberOfSaves: %, timeMax: %, timestep: %", numberOfSaves, timeMax, timestep);
391 std::string line_string;
392 getline(in, line_string);
393 out.str(line_string);
414 file.open(filename.c_str(), std::ios::out);
417 std::cerr <<
"Error in writeToFile: file could not be opened" << std::endl;
431 struct stat stFileInfo;
437 intStat = stat(strFilename.c_str(), &stFileInfo);
468 file.open(filename.c_str(), mode);
484 return mass0 * mass1 / (mass0 + mass1);
MERCURY_DEPRECATED KAndDispAndKtAndDispt computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble beta, Mdouble mass)
Set disp, k, dispt and kt such that is matches a given collision time tc and a normal andtangential r...
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Mdouble getEffectiveMass(Mdouble mass0, Mdouble mass1)
Calculates the effective mass of a particle pair, i.e. half the harmonic mean of two particle masses...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
return type specifically for fuctions returning k and disp at once
MERCURY_DEPRECATED Mdouble computeRestitutionCoefficientFromKAndDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass)
Calculates the restitution coefficient time for a given stiffness, dissipation, and effective mass...
MERCURY_DEPRECATED Mdouble computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass)
Calculates the restitution coefficient for a given stiffness, collision time, and effective mass...
return type specifically for fuctions returning k, disp, kt, dispt at once
LL< Log::ERROR > ERROR
Error log level.
T square(T val)
squares a number
MERCURY_DEPRECATED Mdouble computeKFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass)
Calculates the stiffness for a given collision time, dissipation, and effective mass.
MERCURY_DEPRECATED KAndDisp computeKAndDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass)
Set disp and k such that is matches a given collision time tc and restitution coefficient r for a col...
MERCURY_DEPRECATED Mdouble computeCollisionTimeFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass)
Calculates the collision time for a given stiffness, restitution coefficient, and effective mass...
MERCURY_DEPRECATED Mdouble computeDispFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass)
Calculates the dissipation for a given stiffness, restitution coefficient, and effective mass...
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
MERCURY_DEPRECATED Mdouble computeCollisionTimeFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass)
Calculates the collision time for a given dissipation, restitution coefficient, and effective mass...
MERCURY_DEPRECATED Mdouble computeRestitutionCoefficientFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass)
Calculates the resitution coefficient for a given collision time, dissipation, and effective mass...
MERCURY_DEPRECATED Mdouble computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass)
Calculates the stiffness for a given collision time, restitution coefficient, and effective mass...
MERCURY_DEPRECATED Mdouble computeDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass)
Calculates the dissipation for a given collision time, restitution coefficient, and effective mass...
bool fileExists(std::string strFilename)
Function to check if a file exists, is used to check if a run has already need done.
MERCURY_DEPRECATED Mdouble getMaximumVelocity(Mdouble k, Mdouble disp, Mdouble radius, Mdouble mass)
Calculates the maximum relative velocity allowed for a normal collision of two particles of radius r ...
MERCURY_DEPRECATED Mdouble computeCollisionTimeFromKAndDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass)
Calculates the collision time for a given stiffness, dissipation, and effective mass.
bool openFile(std::fstream &file, std::string filename, std::fstream::openmode mode)
Provides a simple interface for opening a file.
MERCURY_DEPRECATED Mdouble computeKFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass)
Calculates the stiffness for a given dissipation, restitution coefficient, and effective mass...
MERCURY_DEPRECATED Mdouble computeDispFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass)
Calculates the dissipation for a given stiffness, collision time, and effective mass.
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...